<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>悦音阁 - 简约音乐平台</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        /* ===== 重置样式 ===== */
        * {
            margin: 0;
            padding: 0
            box-sizing: border-box;
            font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', Arial, sans-serif;
            -webkit-tap-highlight-color: transparent;
        }

        /* ===== CSS变量定义 ===== */
        :root {
            /* 主色调 - 简约Ins风 */
            --primary: #FF2D55;
            --primary-light: #FF6B8B;
            --primary-dark: #D81B60;
            --accent: #5856D6;
            --accent-light: #7D7AFF;
            
            /* 中性色 - 简约灰白 */
            --bg-primary: #FFFFFF;
            --bg-secondary: #F8F9FA;
            --bg-tertiary: #F1F3F4;
            --bg-card: #FFFFFF;
            
            /* 文字色 */
            --text-primary: #1D1D1F;
            --text-secondary: #86868B;
            --text-tertiary: #AEAEB2;
            --text-white: #FFFFFF;
            
            /* 边框和阴影 */
            --border-light: #E5E5E7;
            --border-medium: #D2D2D7;
            --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
            --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
            --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
            
            /* 功能色 */
            --success: #34C759;
            --warning: #FF9500;
            --error: #FF3B30;
            --info: #007AFF;
            
            /* 尺寸变量 */
            --sidebar-width: 280px;
            --player-height: 80px;
            --header-height: 60px;
            --border-radius-sm: 8px;
            --border-radius-md: 12px;
            --border-radius-lg: 16px;
            --border-radius-xl: 20px;
            
            /* 动画 */
            --transition-fast: 0.2s ease;
            --transition-normal: 0.3s ease;
            --transition-slow: 0.5s ease;
            
            /* 模糊效果 */
            --blur-bg: blur(20px);
        }

        /* 深色主题变量 */
        [data-theme="dark"] {
            --bg-primary: #000000;
            --bg-secondary: #1C1C1E;
            --bg-tertiary: #2C2C2E;
            --bg-card: #1C1C1E;
            
            --text-primary: #FFFFFF;
            --text-secondary: #98989E;
            --text-tertiary: #636366;
            
            --border-light: #38383A;
            --border-medium: #48484A;
            
            --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.16);
            --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.24);
            --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.32);
        }

        /* ===== 基础样式 ===== */
        body {
            background: var(--bg-primary);
            color: var(--text-primary);
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            overflow-x: hidden;
            transition: all var(--transition-normal);
            line-height: 1.6;
        }

        /* ===== 滚动条优化 ===== */
        ::-webkit-scrollbar {
            width: 6px;
            height: 6px;
        }

        ::-webkit-scrollbar-track {
            background: transparent;
            border-radius: 3px;
        }

        ::-webkit-scrollbar-thumb {
            background: var(--text-tertiary);
            border-radius: 3px;
            transition: background var(--transition-fast);
        }

        ::-webkit-scrollbar-thumb:hover {
            background: var(--text-secondary);
        }

        /* ===== 布局组件 ===== */
        .main-container {
            display: flex;
            flex: 1;
            padding-bottom: var(--player-height);
            position: relative;
        }

        /* ===== 侧边栏样式 ===== */
        .sidebar {
            width: var(--sidebar-width);
            background: var(--bg-card);
            height: calc(100vh - var(--player-height));
            position: fixed;
            left: 0;
            top: 0;
            padding: 20px 0;
            overflow-y: auto;
            z-index: 1000;
            display: flex;
            flex-direction: column;
            border-right: 1px solid var(--border-light);
            transition: transform var(--transition-normal), background var(--transition-normal);
            box-shadow: var(--shadow-sm);
        }

        .logo {
            display: flex;
            align-items: center;
            gap: 12px;
            font-size: 24px;
            font-weight: 700;
            color: var(--text-primary);
            padding: 0 24px 20px;
            margin-bottom: 20px;
            border-bottom: 1px solid var(--border-light);
            cursor: pointer;
            user-select: none;
        }

        .logo i {
            color: var(--primary);
            font-size: 28px;
        }

        .nav-section {
            margin-bottom: 32px;
            padding: 0 16px;
        }

        .nav-title {
            font-size: 13px;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            color: var(--text-tertiary);
            padding: 0 8px 12px;
            margin-bottom: 8px;
        }

        .nav-links {
            list-style: none;
        }

        .nav-links li {
            margin-bottom: 4px;
        }

        .nav-links a {
            display: flex;
            align-items: center;
            gap: 16px;
            color: var(--text-secondary);
            text-decoration: none;
            font-weight: 500;
            padding: 12px 16px;
            border-radius: var(--border-radius-md);
            transition: all var(--transition-fast);
            font-size: 15px;
            position: relative;
        }

        .nav-links a:hover {
            color: var(--text-primary);
            background: var(--bg-tertiary);
            transform: translateX(4px);
        }

        .nav-links a.active {
            color: var(--primary);
            background: var(--bg-tertiary);
            font-weight: 600;
        }

        .nav-links a i {
            width: 20px;
            text-align: center;
            font-size: 18px;
            transition: transform var(--transition-fast);
        }

        .nav-links a:hover i {
            transform: scale(1.1);
        }

        /* ===== 主内容区 ===== */
        .content {
            flex: 1;
            margin-left: var(--sidebar-width);
            padding: 24px;
            min-height: calc(100vh - var(--player-height));
            transition: margin-left var(--transition-normal);
            background: var(--bg-secondary);
        }

        /* ===== 顶部导航 ===== */
        .top-nav {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 32px;
            padding: 16px 0;
        }

        .search-container {
            background: var(--bg-card);
            border-radius: var(--border-radius-lg);
            padding: 12px 20px;
            display: flex;
            align-items: center;
            gap: 12px;
            width: 400px;
            border: 1.5px solid var(--border-light);
            transition: all var(--transition-fast);
            position: relative;
        }

        .search-container:focus-within {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(255, 45, 85, 0.1);
        }

        .search-container input {
            background: none;
            border: none;
            color: var(--text-primary);
            width: 100%;
            outline: none;
            font-size: 16px;
            font-weight: 500;
        }

        .search-container input::placeholder {
            color: var(--text-tertiary);
        }

        .search-container i {
            color: var(--text-tertiary);
            transition: color var(--transition-fast);
        }

        .search-container:focus-within i {
            color: var(--primary);
        }

        .search-suggestions,
        .search-history {
            position: absolute;
            top: 100%;
            left: 0;
            right: 0;
            background: var(--bg-card);
            border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
            max-height: 280px;
            overflow-y: auto;
            display: none;
            z-index: 100;
            box-shadow: var(--shadow-lg);
            border: 1.5px solid var(--border-light);
            border-top: none;
            margin-top: -1px;
        }

        .search-suggestion,
        .search-history-item {
            padding: 16px 20px;
            cursor: pointer;
            border-bottom: 1px solid var(--border-light);
            display: flex;
            align-items: center;
            gap: 12px;
            color: var(--text-primary);
            transition: background var(--transition-fast);
            font-size: 15px;
        }

        .search-suggestion:hover,
        .search-history-item:hover {
            background: var(--bg-tertiary);
        }

        .search-suggestion i {
            color: var(--primary);
            width: 20px;
        }

        .search-history-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 16px 20px;
            border-bottom: 1px solid var(--border-light);
            font-weight: 600;
            color: var(--text-primary);
        }

        .search-history-text {
            display: flex;
            align-items: center;
            gap: 12px;
            flex: 1;
        }

        #clearSearchHistory,
        .delete-search-item {
            background: none;
            border: none;
            color: var(--text-tertiary);
            cursor: pointer;
            font-size: 14px;
            transition: color var(--transition-fast);
            padding: 4px 8px;
            border-radius: var(--border-radius-sm);
        }

        #clearSearchHistory:hover,
        .delete-search-item:hover {
            color: var(--primary);
            background: var(--bg-tertiary);
        }

        .user-actions {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .theme-toggle {
            background: var(--bg-card);
            border: 1.5px solid var(--border-light);
            color: var(--text-secondary);
            width: 44px;
            height: 44px;
            border-radius: var(--border-radius-md);
            cursor: pointer;
            transition: all var(--transition-fast);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
        }

        .theme-toggle:hover {
            border-color: var(--primary);
            color: var(--primary);
            transform: scale(1.05);
        }

        /* ===== 欢迎横幅 ===== */
        .welcome-banner {
            background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
            border-radius: var(--border-radius-lg);
            padding: 32px;
            margin-bottom: 32px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            position: relative;
            overflow: hidden;
            box-shadow: var(--shadow-md);
        }

        .welcome-banner::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none"><path d="M0,0 L100,0 L100,100 Z" fill="rgba(255,255,255,0.1)"/></svg>');
            background-size: cover;
        }

        .welcome-text h1 {
            font-size: 32px;
            margin-bottom: 8px;
            color: var(--text-white);
            font-weight: 700;
            position: relative;
        }

        .welcome-text p {
            color: rgba(255, 255, 255, 0.9);
            font-size: 16px;
            position: relative;
        }

        .play-shuffle-btn {
            background: var(--text-white);
            color: var(--primary);
            border: none;
            padding: 14px 28px;
            border-radius: var(--border-radius-lg);
            font-weight: 600;
            font-size: 15px;
            cursor: pointer;
            transition: all var(--transition-fast);
            display: flex;
            align-items: center;
            gap: 8px;
            position: relative;
            z-index: 1;
            box-shadow: var(--shadow-sm);
        }

        .play-shuffle-btn:hover {
            transform: translateY(-2px);
            box-shadow: var(--shadow-md);
        }

        /* ===== 内容区块 ===== */
        .section-title {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin: 48px 0 24px;
        }

        .section-title h2 {
            font-size: 24px;
            font-weight: 700;
            color: var(--text-primary);
        }

        .see-all {
            color: var(--primary);
            font-size: 15px;
            font-weight: 600;
            text-decoration: none;
            transition: all var(--transition-fast);
            padding: 8px 16px;
            border-radius: var(--border-radius-md);
        }

        .see-all:hover {
            background: var(--bg-tertiary);
            transform: translateX(4px);
        }

        /* ===== 卡片网格 ===== */
        .cards-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
            gap: 24px;
            margin-bottom: 48px;
        }

        .card {
            background: var(--bg-card);
            border-radius: var(--border-radius-lg);
            padding: 20px;
            transition: all var(--transition-normal);
            cursor: pointer;
            position: relative;
            overflow: hidden;
            border: 1px solid var(--border-light);
            box-shadow: var(--shadow-sm);
        }

        .card:hover {
            transform: translateY(-8px);
            box-shadow: var(--shadow-lg);
            border-color: var(--primary-light);
        }

        .card-image {
            width: 100%;
            aspect-ratio: 1;
            border-radius: var(--border-radius-md);
            margin-bottom: 16px;
            overflow: hidden;
            position: relative;
            background: linear-gradient(135deg, var(--primary), var(--accent));
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--text-white);
        }

        .card-image img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            transition: transform var(--transition-normal);
        }

        .card:hover .card-image img {
            transform: scale(1.08);
        }

        .card-play-btn {
            position: absolute;
            bottom: 12px;
            right: 12px;
            background: var(--primary);
            color: var(--text-white);
            width: 44px;
            height: 44px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 0;
            transform: translateY(8px);
            transition: all var(--transition-normal);
            box-shadow: var(--shadow-md);
            z-index: 2;
        }

        .card:hover .card-play-btn {
            opacity: 1;
            transform: translateY(0);
        }

        .card-title {
            font-weight: 600;
            margin-bottom: 8px;
            font-size: 16px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            color: var(--text-primary);
        }

        .card-description {
            color: var(--text-secondary);
            font-size: 14px;
            line-height: 1.5;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }

        /* ===== 播放列表区域 ===== */
        .playlist-section {
            background: var(--bg-card);
            border-radius: var(--border-radius-lg);
            padding: 24px;
            margin-top: 24px;
            border: 1px solid var(--border-light);
            box-shadow: var(--shadow-sm);
        }

        .playlist-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 24px;
            flex-wrap: wrap;
            gap: 16px;
        }

        .playlist-title {
            font-size: 20px;
            font-weight: 700;
            color: var(--text-primary);
        }

        .source-selector {
            display: flex;
            gap: 8px;
            background: var(--bg-tertiary);
            padding: 6px;
            border-radius: var(--border-radius-md);
            flex-wrap: wrap;
        }

        .source-btn {
            background: transparent;
            border: none;
            color: var(--text-secondary);
            padding: 8px 16px;
            border-radius: var(--border-radius-sm);
            cursor: pointer;
            transition: all var(--transition-fast);
            font-size: 14px;
            font-weight: 500;
        }

        .source-btn.active {
            background: var(--bg-card);
            color: var(--text-primary);
            box-shadow: var(--shadow-sm);
        }

        .source-btn:hover:not(.active) {
            color: var(--text-primary);
        }

        .song-list {
            display: flex;
            flex-direction: column;
            gap: 8px;
            position: relative;
            overflow-y: auto;
            max-height: 500px;
        }

        .song-item {
            display: flex;
            align-items: center;
            padding: 16px;
            border-radius: var(--border-radius-md);
            transition: all var(--transition-fast);
            cursor: pointer;
            border: 1px solid transparent;
        }

        .song-item:hover {
            background: var(--bg-tertiary);
            border-color: var(--border-light);
            transform: translateX(4px);
        }

        .song-item.active {
            background: rgba(255, 45, 85, 0.08);
            border-color: var(--primary-light);
        }

        .song-number {
            width: 32px;
            text-align: center;
            color: var(--text-tertiary);
            font-size: 14px;
            font-weight: 500;
        }

        .song-info {
            flex: 1;
            margin-left: 16px;
            overflow: hidden;
        }

        .song-name {
            font-weight: 600;
            margin-bottom: 4px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            color: var(--text-primary);
        }

        .song-artist {
            font-size: 14px;
            color: var(--text-secondary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .song-duration {
            color: var(--text-tertiary);
            font-size: 14px;
            font-weight: 500;
            margin-right: 16px;
        }

        .song-actions {
            display: flex;
            gap: 8px;
            opacity: 0;
            transition: opacity var(--transition-fast);
        }

        .song-item:hover .song-actions {
            opacity: 1;
        }

        .song-action-btn {
            background: none;
            border: none;
            color: var(--text-tertiary);
            cursor: pointer;
            font-size: 16px;
            transition: all var(--transition-fast);
            width: 36px;
            height: 36px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .song-action-btn:hover {
            color: var(--primary);
            background: var(--bg-tertiary);
        }

        .song-action-btn.favorited {
            color: var(--primary);
        }

        /* ===== 播放器样式 ===== */
        .player {
            position: fixed;
            bottom: 0;
            left: 0;
            width: 100%;
            height: var(--player-height);
            background: var(--bg-card);
            border-top: 1px solid var(--border-light);
            display: flex;
            align-items: center;
            padding: 0 24px;
            z-index: 2000;
            transition: all var(--transition-normal);
            box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.08);
        }

        .player-album-art {
            width: 56px;
            height: 56px;
            border-radius: var(--border-radius-md);
            margin-right: 16px;
            background: linear-gradient(135deg, var(--primary), var(--accent));
            overflow: hidden;
            flex-shrink: 0;
            position: relative;
            box-shadow: var(--shadow-sm);
        }

        .player-album-art img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .player-song-info {
            flex: 0 0 200px;
            margin-right: 24px;
            min-width: 0;
        }

        .player-song-title {
            font-weight: 600;
            font-size: 15px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            color: var(--text-primary);
        }

        .player-song-artist {
            font-size: 14px;
            color: var(--text-secondary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .player-controls {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            max-width: 500px;
        }

        .player-buttons {
            display: flex;
            align-items: center;
            gap: 20px;
            margin-bottom: 12px;
        }

        .control-btn {
            background: none;
            border: none;
            color: var(--text-secondary);
            font-size: 16px;
            cursor: pointer;
            transition: all var(--transition-fast);
            width: 36px;
            height: 36px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .control-btn:hover {
            color: var(--text-primary);
            background: var(--bg-tertiary);
            transform: scale(1.1);
        }

        .play-btn {
            background: var(--primary);
            color: var(--text-white);
            width: 44px;
            height: 44px;
            font-size: 16px;
            box-shadow: var(--shadow-sm);
        }

        .play-btn:hover {
            background: var(--primary-light);
            transform: scale(1.05);
        }

        .player-progress {
            display: flex;
            align-items: center;
            gap: 12px;
            width: 100%;
        }

        .player-time {
            font-size: 13px;
            color: var(--text-tertiary);
            min-width: 40px;
            font-weight: 500;
        }

        .progress-bar {
            flex: 1;
            height: 4px;
            background: var(--border-light);
            border-radius: 2px;
            cursor: pointer;
            position: relative;
            overflow: hidden;
            transition: height var(--transition-fast);
        }

        .progress-bar:hover {
            height: 6px;
        }

        .progress {
            height: 100%;
            background: var(--primary);
            width: 0%;
            border-radius: 2px;
            transition: width 0.1s;
        }

        .player-extra {
            flex: 0 0 200px;
            display: flex;
            align-items: center;
            justify-content: flex-end;
            gap: 16px;
        }

        .volume-container {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .volume-slider {
            width: 80px;
            -webkit-appearance: none;
            height: 4px;
            background: var(--border-light);
            border-radius: 2px;
            outline: none;
            transition: height var(--transition-fast);
        }

        .volume-slider:hover {
            height: 6px;
        }

        .volume-slider::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background: var(--primary);
            cursor: pointer;
            transition: all var(--transition-fast);
        }

        .volume-slider::-webkit-slider-thumb:hover {
            background: var(--primary-light);
            transform: scale(1.2);
        }

        /* ===== 歌词面板 ===== */
        .lyrics-panel {
            position: fixed;
            right: -400px;
            top: 0;
            width: 400px;
            height: 100vh;
            background: var(--bg-card);
            z-index: 1500;
            padding: 24px;
            transition: right var(--transition-normal);
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            border-left: 1px solid var(--border-light);
            box-shadow: var(--shadow-lg);
        }

        .lyrics-panel.open {
            right: 0;
        }

        .lyrics-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 32px;
            padding-bottom: 16px;
            border-bottom: 1px solid var(--border-light);
        }

        .lyrics-title {
            font-size: 20px;
            font-weight: 700;
            color: var(--text-primary);
        }

        .close-lyrics {
            background: none;
            border: none;
            color: var(--text-tertiary);
            font-size: 20px;
            cursor: pointer;
            transition: all var(--transition-fast);
            width: 36px;
            height: 36px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .close-lyrics:hover {
            color: var(--text-primary);
            background: var(--bg-tertiary);
        }

        .lyrics-album-section {
            display: flex;
            flex-direction: column;
            align-items: center;
            margin-bottom: 32px;
            gap: 16px;
        }

        .lyrics-album-art {
            width: 200px;
            height: 200px;
            border-radius: var(--border-radius-lg);
            overflow: hidden;
            box-shadow: var(--shadow-lg);
            background: linear-gradient(135deg, var(--primary), var(--accent));
        }

        .lyrics-album-art img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .lyrics-song-info {
            text-align: center;
        }

        .lyrics-song-title {
            font-size: 20px;
            font-weight: 700;
            margin-bottom: 8px;
            color: var(--text-primary);
        }

        .lyrics-song-artist {
            font-size: 16px;
            color: var(--text-secondary);
        }

        .lyrics-container {
            text-align: center;
            line-height: 2.2;
            font-size: 18px;
            color: var(--text-secondary);
            min-height: 200px;
            flex: 1;
            overflow-y: auto;
            padding: 16px;
            position: relative;
        }

        .lyric-line {
            margin: 12px 0;
            transition: all var(--transition-normal);
            opacity: 0.6;
            padding: 8px 12px;
            border-radius: var(--border-radius-md);
            font-weight: 500;
        }

        .current-lyric {
            color: var(--primary);
            font-weight: 700;
            font-size: 20px;
            margin: 16px 0;
            transition: all var(--transition-normal);
            padding: 12px 16px;
            border-radius: var(--border-radius-md);
            background: rgba(255, 45, 85, 0.08);
            opacity: 1;
            transform: scale(1.02);
        }

        .no-lyrics {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 70%;
            gap: 20px;
            color: var(--text-tertiary);
        }

        .no-lyrics i {
            font-size: 48px;
            opacity: 0.5;
        }

        .toggle-lyrics {
            background: none;
            border: none;
            color: var(--text-tertiary);
            font-size: 18px;
            cursor: pointer;
            transition: all var(--transition-fast);
            width: 36px;
            height: 36px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .toggle-lyrics:hover {
            color: var(--primary);
            background: var(--bg-tertiary);
        }

        /* ===== 全屏模式 ===== */
        .fullscreen-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: var(--bg-primary);
            z-index: 3000;
            display: none;
            flex-direction: column;
            color: var(--text-primary);
            box-sizing: border-box;
            overflow: hidden;
        }

        .fullscreen-overlay.active {
            display: flex;
        }

        .fullscreen-header {
            padding: 24px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px solid var(--border-light);
            background: var(--bg-card);
        }

        .fullscreen-content {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 40px;
            gap: 40px;
            position: relative;
            overflow: hidden;
        }

        .fullscreen-album-art {
            width: 300px;
            height: 300px;
            border-radius: var(--border-radius-xl);
            box-shadow: var(--shadow-lg);
            overflow: hidden;
            background: linear-gradient(135deg, var(--primary), var(--accent));
            position: relative;
        }

        .fullscreen-album-art img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .fullscreen-info {
            text-align: center;
            max-width: 600px;
            width: 100%;
        }

        .fullscreen-title {
            font-size: 32px;
            font-weight: 700;
            margin-bottom: 12px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            color: var(--text-primary);
        }

        .fullscreen-artist {
            font-size: 20px;
            color: var(--text-secondary);
            margin-bottom: 8px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .fullscreen-album {
            font-size: 16px;
            color: var(--text-tertiary);
            margin-bottom: 32px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .fullscreen-progress {
            width: 100%;
            max-width: 500px;
            margin-bottom: 32px;
        }

        .fullscreen-time-info {
            display: flex;
            justify-content: space-between;
            margin-bottom: 12px;
            font-size: 14px;
            color: var(--text-tertiary);
            font-weight: 500;
        }

        .fullscreen-progress-bar {
            width: 100%;
            height: 6px;
            background: var(--border-light);
            border-radius: 3px;
            cursor: pointer;
            position: relative;
            overflow: hidden;
            transition: height var(--transition-fast);
        }

        .fullscreen-progress-bar:hover {
            height: 8px;
        }

        .fullscreen-progress {
            height: 100%;
            background: var(--primary);
            width: 0%;
            border-radius: 3px;
            transition: width 0.1s;
        }

        .fullscreen-controls {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 24px;
            margin-top: 24px;
        }

        .fullscreen-control-btn {
            background: var(--bg-tertiary);
            border: none;
            color: var(--text-primary);
            width: 56px;
            height: 56px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            cursor: pointer;
            transition: all var(--transition-fast);
            box-shadow: var(--shadow-sm);
        }

        .fullscreen-control-btn:hover {
            background: var(--border-light);
            transform: scale(1.1);
        }

        .fullscreen-play-btn {
            width: 64px;
            height: 64px;
            font-size: 24px;
            background: var(--primary);
            color: var(--text-white);
        }

        .fullscreen-play-btn:hover {
            background: var(--primary-light);
        }

        .fullscreen-favorite-btn {
            color: var(--text-primary);
        }

        .fullscreen-favorite-btn.favorited {
            color: var(--primary);
        }

        .fullscreen-lyrics {
            font-size: 20px;
            text-align: center;
            line-height: 2;
            max-width: 800px;
            margin: 0 auto;
            padding: 0 24px;
            overflow-y: auto;
            max-height: 200px;
            width: 100%;
            color: var(--text-secondary);
        }

        .fullscreen-lyrics .lyric-line {
            margin: 16px 0;
            transition: all var(--transition-normal);
            opacity: 0.6;
            padding: 8px 16px;
            border-radius: var(--border-radius-md);
        }

        .fullscreen-lyrics .current-lyric {
            color: var(--primary);
            font-weight: 700;
            font-size: 24px;
            margin: 20px 0;
            transition: all var(--transition-normal);
            padding: 12px 20px;
            border-radius: var(--border-radius-md);
            background: rgba(255, 45, 85, 0.08);
            opacity: 1;
            transform: scale(1.02);
        }

        .fullscreen-exit {
            background: var(--bg-tertiary);
            border: none;
            color: var(--text-primary);
            width: 44px;
            height: 44px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            cursor: pointer;
            transition: all var(--transition-fast);
        }

        .fullscreen-exit:hover {
            background: var(--border-light);
            transform: scale(1.1);
        }

        /* ===== 移动端控制按钮 ===== */
        .mobile-controls {
            display: none;
            position: fixed;
            bottom: calc(var(--player-height) + 16px);
            left: 0;
            width: 100%;
            justify-content: center;
            gap: 16px;
            padding: 16px;
            z-index: 1900;
            background: rgba(255, 255, 255, 0.9);
            backdrop-filter: blur(20px);
            border-top: 1px solid var(--border-light);
        }

        [data-theme="dark"] .mobile-controls {
            background: rgba(28, 28, 30, 0.9);
        }

        .mobile-control-btn {
            background: var(--bg-card);
            border: 1px solid var(--border-light);
            color: var(--text-primary);
            width: 52px;
            height: 52px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            cursor: pointer;
            transition: all var(--transition-fast);
            box-shadow: var(--shadow-sm);
        }

        .mobile-control-btn:hover {
            background: var(--bg-tertiary);
            transform: scale(1.1);
        }

        /* ===== 移动端菜单切换按钮 ===== */
        .mobile-menu-toggle {
            display: none;
            position: fixed;
            top: 20px;
            left: 20px;
            z-index: 1100;
            background: var(--primary);
            color: var(--text-white);
            border: none;
            border-radius: 50%;
            width: 44px;
            height: 44px;
            font-size: 18px;
            cursor: pointer;
            align-items: center;
            justify-content: center;
            transition: all var(--transition-fast);
            box-shadow: var(--shadow-md);
        }

        .mobile-menu-toggle:hover {
            background: var(--primary-light);
            transform: scale(1.1);
        }

        /* ===== 错误和加载状态 ===== */
        .error-message {
            background: rgba(255, 59, 48, 0.08);
            border-left: 4px solid var(--error);
            padding: 16px;
            border-radius: var(--border-radius-md);
            margin-bottom: 20px;
            display: none;
            align-items: center;
            gap: 12px;
            color: var(--error);
            font-weight: 500;
        }

        .error-message.show {
            display: flex;
        }

        .loading {
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 40px;
            flex-direction: column;
            gap: 16px;
            color: var(--text-tertiary);
        }

        .loading i {
            font-size: 32px;
            animation: spin 1s linear infinite;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        /* ===== 下载模态框 ===== */
        .download-modal {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.6);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 4000;
            backdrop-filter: blur(8px);
            opacity: 0;
            visibility: hidden;
            transition: all var(--transition-normal);
        }

        .download-modal.active {
            opacity: 1;
            visibility: visible;
        }

        .download-container {
            background: var(--bg-card);
            border-radius: var(--border-radius-lg);
            width: 90%;
            max-width: 500px;
            max-height: 80vh;
            padding: 32px;
            box-shadow: var(--shadow-lg);
            transform: translateY(20px) scale(0.95);
            transition: all var(--transition-normal);
            overflow-y: auto;
            border: 1px solid var(--border-light);
        }

        .download-modal.active .download-container {
            transform: translateY(0) scale(1);
        }

        .download-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 24px;
            padding-bottom: 16px;
            border-bottom: 1px solid var(--border-light);
        }

        .download-title {
            font-size: 24px;
            font-weight: 700;
            color: var(--text-primary);
        }

        .close-download {
            background: none;
            border: none;
            color: var(--text-tertiary);
            font-size: 20px;
            cursor: pointer;
            transition: all var(--transition-fast);
            width: 36px;
            height: 36px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .close-download:hover {
            color: var(--text-primary);
            background: var(--bg-tertiary);
        }

        .download-options {
            display: flex;
            flex-direction: column;
            gap: 20px;
            margin-bottom: 32px;
        }

        .download-option {
            display: flex;
            align-items: flex-start;
            gap: 12px;
        }

        .download-option input[type="checkbox"] {
            width: 20px;
            height: 20px;
            accent-color: var(--primary);
            margin-top: 2px;
        }

        .download-option label {
            font-size: 16px;
            color: var(--text-primary);
            font-weight: 500;
            flex: 1;
        }

        .download-format-group {
            margin-left: 32px;
            margin-top: 12px;
            width: 100%;
        }

        .format-group-title {
            font-size: 14px;
            color: var(--text-secondary);
            margin-bottom: 12px;
            font-weight: 500;
        }

        .download-format-options {
            display: flex;
            gap: 20px;
            flex-wrap: wrap;
        }

        .download-format-option {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .download-format-option input[type="radio"] {
            accent-color: var(--primary);
        }

        .download-format-option label {
            font-size: 14px;
            color: var(--text-secondary);
            font-weight: normal;
        }

        .download-actions {
            display: flex;
            justify-content: flex-end;
            gap: 12px;
            margin-top: 24px;
        }

        .download-confirm-btn,
        .download-cancel-btn {
            border: none;
            border-radius: var(--border-radius-md);
            padding: 12px 24px;
            font-weight: 600;
            cursor: pointer;
            transition: all var(--transition-fast);
            font-size: 15px;
        }

        .download-confirm-btn {
            background: var(--primary);
            color: var(--text-white);
        }

        .download-confirm-btn:hover {
            background: var(--primary-light);
            transform: translateY(-2px);
        }

        .download-cancel-btn {
            background: var(--bg-tertiary);
            color: var(--text-primary);
        }

        .download-cancel-btn:hover {
            background: var(--border-light);
            transform: translateY(-2px);
        }

        /* ===== 成功提示 ===== */
        .success-toast {
            position: fixed;
            top: 24px;
            right: 24px;
            background: var(--success);
            color: var(--text-white);
            padding: 16px 24px;
            border-radius: var(--border-radius-md);
            z-index: 5000;
            box-shadow: var(--shadow-lg);
            animation: slideInRight 0.3s ease;
            display: flex;
            align-items: center;
            gap: 12px;
            font-weight: 500;
            max-width: 400px;
        }

        @keyframes slideInRight {
            from { transform: translateX(100%); opacity: 0; }
            to { transform: translateX(0); opacity: 1; }
        }

        @keyframes slideOutRight {
            from { transform: translateX(0); opacity: 1; }
            to { transform: translateX(100%); opacity: 0; }
        }

        /* ===== 待播放列表面板 ===== */
        .upnext-panel {
            position: fixed;
            right: -400px;
            top: 0;
            width: 400px;
            height: 100vh;
            background: var(--bg-card);
            z-index: 1500;
            padding: 24px;
            transition: right var(--transition-normal);
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            border-left: 1px solid var(--border-light);
            box-shadow: var(--shadow-lg);
        }

        .upnext-panel.open {
            right: 0;
        }

        .upnext-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 24px;
            padding-bottom: 16px;
            border-bottom: 1px solid var(--border-light);
        }

        .upnext-title {
            font-size: 20px;
            font-weight: 700;
            color: var(--text-primary);
        }

        .close-upnext {
            background: none;
            border: none;
            color: var(--text-tertiary);
            font-size: 20px;
            cursor: pointer;
            transition: all var(--transition-fast);
            width: 36px;
            height: 36px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .close-upnext:hover {
            color: var(--text-primary);
            background: var(--bg-tertiary);
        }

        .upnext-actions {
            display: flex;
            justify-content: space-between;
            margin-bottom: 16px;
            gap: 12px;
        }

        .upnext-action-btn {
            background: var(--bg-tertiary);
            border: none;
            color: var(--text-secondary);
            padding: 8px 16px;
            border-radius: var(--border-radius-md);
            cursor: pointer;
            transition: all var(--transition-fast);
            font-size: 14px;
            font-weight: 500;
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
        }

        .upnext-action-btn:hover {
            background: var(--border-light);
            color: var(--text-primary);
        }

        .upnext-list {
            flex: 1;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .upnext-item {
            display: flex;
            align-items: center;
            padding: 12px;
            border-radius: var(--border-radius-md);
            transition: all var(--transition-fast);
            cursor: pointer;
            border: 1px solid transparent;
        }

        .upnext-item:hover {
            background: var(--bg-tertiary);
            border-color: var(--border-light);
        }

        .upnext-item.active {
            background: rgba(255, 45, 85, 0.08);
            border-color: var(--primary-light);
        }

        .upnext-number {
            width: 24px;
            text-align: center;
            color: var(--text-tertiary);
            font-size: 14px;
            font-weight: 500;
        }

        .upnext-info {
            flex: 1;
            margin-left: 12px;
            overflow: hidden;
        }

        .upnext-name {
            font-weight: 600;
            margin-bottom: 2px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            color: var(--text-primary);
            font-size: 14px;
        }

        .upnext-artist {
            font-size: 12px;
            color: var(--text-secondary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .upnext-actions-item {
            display: flex;
            gap: 4px;
            opacity: 0;
            transition: opacity var(--transition-fast);
        }

        .upnext-item:hover .upnext-actions-item {
            opacity: 1;
        }

        .upnext-action-btn-item {
            background: none;
            border: none;
            color: var(--text-tertiary);
            cursor: pointer;
            font-size: 14px;
            transition: all var(--transition-fast);
            width: 28px;
            height: 28px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .upnext-action-btn-item:hover {
            color: var(--primary);
            background: var(--bg-tertiary);
        }

        .upnext-empty {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100%;
            gap: 20px;
            color: var(--text-tertiary);
            text-align: center;
            padding: 40px 20px;
        }

        .upnext-empty i {
            font-size: 48px;
            opacity: 0.5;
        }

        .upnext-empty p {
            font-size: 16px;
            max-width: 300px;
            line-height: 1.5;
        }

        /* ===== 待播放列表按钮 ===== */
        .upnext-toggle {
            background: none;
            border: none;
            color: var(--text-tertiary);
            font-size: 18px;
            cursor: pointer;
            transition: all var(--transition-fast);
            width: 36px;
            height: 36px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .upnext-toggle:hover {
            color: var(--primary);
            background: var(--bg-tertiary);
        }

        /* ===== 后台管理面板 ===== */
        .admin-panel {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: var(--bg-primary);
            z-index: 4000;
            display: none;
            flex-direction: column;
            color: var(--text-primary);
            box-sizing: border-box;
            overflow: hidden;
        }

        .admin-panel.active {
            display: flex;
        }

        .admin-header {
            padding: 20px 24px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px solid var(--border-light);
            background: var(--bg-card);
        }

        .admin-title {
            font-size: 24px;
            font-weight: 700;
            color: var(--text-primary);
        }

        .admin-close {
            background: var(--bg-tertiary);
            border: none;
            color: var(--text-primary);
            width: 44px;
            height: 44px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            cursor: pointer;
            transition: all var(--transition-fast);
        }

        .admin-close:hover {
            background: var(--border-light);
            transform: scale(1.1);
        }

        .admin-content {
            flex: 1;
            display: flex;
            padding: 24px;
            gap: 24px;
            overflow: hidden;
        }

        .admin-sidebar {
            width: 250px;
            background: var(--bg-card);
            border-radius: var(--border-radius-lg);
            padding: 20px;
            border: 1px solid var(--border-light);
            box-shadow: var(--shadow-sm);
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .admin-tab {
            padding: 16px;
            border-radius: var(--border-radius-md);
            background: var(--bg-tertiary);
            color: var(--text-secondary);
            font-weight: 600;
            cursor: pointer;
            transition: all var(--transition-fast);
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .admin-tab.active {
            background: var(--primary);
            color: var(--text-white);
        }

        .admin-tab:hover:not(.active) {
            background: var(--border-light);
            color: var(--text-primary);
        }

        .admin-main {
            flex: 1;
            background: var(--bg-card);
            border-radius: var(--border-radius-lg);
            padding: 24px;
            border: 1px solid var(--border-light);
            box-shadow: var(--shadow-sm);
            overflow-y: auto;
        }

        .admin-section {
            display: none;
        }

        .admin-section.active {
            display: block;
        }

        .section-title {
            font-size: 20px;
            font-weight: 700;
            margin-bottom: 20px;
            color: var(--text-primary);
        }

        .feedback-list {
            display: flex;
            flex-direction: column;
            gap: 16px;
        }

        .feedback-item {
            background: var(--bg-tertiary);
            border-radius: var(--border-radius-md);
            padding: 20px;
            border: 1px solid var(--border-light);
        }

        .feedback-header {
            display: flex;
            justify-content: space-between;
            margin-bottom: 12px;
        }

        .feedback-email {
            font-weight: 600;
            color: var(--text-primary);
        }

        .feedback-date {
            color: var(--text-tertiary);
            font-size: 14px;
        }

        .feedback-content {
            color: var(--text-secondary);
            line-height: 1.5;
        }

        .user-data-list {
            display: flex;
            flex-direction: column;
            gap: 16px;
        }

        .user-data-item {
            background: var(--bg-tertiary);
            border-radius: var(--border-radius-md);
            padding: 20px;
            border: 1px solid var(--border-light);
        }

        .user-data-header {
            display: flex;
            justify-content: space-between;
            margin-bottom: 12px;
        }

        .user-data-id {
            font-weight: 600;
            color: var(--text-primary);
        }

        .user-data-date {
            color: var(--text-tertiary);
            font-size: 14px;
        }

        .user-data-content {
            color: var(--text-secondary);
            line-height: 1.5;
            max-height: 200px;
            overflow-y: auto;
        }

        .admin-actions {
            display: flex;
            gap: 12px;
            margin-top: 20px;
        }

        .admin-btn {
            padding: 12px 20px;
            border-radius: var(--border-radius-md);
            border: none;
            font-weight: 600;
            cursor: pointer;
            transition: all var(--transition-fast);
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .admin-btn.primary {
            background: var(--primary);
            color: var(--text-white);
        }

        .admin-btn.primary:hover {
            background: var(--primary-light);
            transform: translateY(-2px);
        }

        .admin-btn.secondary {
            background: var(--bg-tertiary);
            color: var(--text-primary);
        }

        .admin-btn.secondary:hover {
            background: var(--border-light);
            transform: translateY(-2px);
        }

        /* ===== 意见反馈表单 ===== */
        .feedback-modal {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.6);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 4000;
            backdrop-filter: blur(8px);
            opacity: 0;
            visibility: hidden;
            transition: all var(--transition-normal);
        }

        .feedback-modal.active {
            opacity: 1;
            visibility: visible;
        }

        .feedback-container {
            background: var(--bg-card);
            border-radius: var(--border-radius-lg);
            width: 90%;
            max-width: 500px;
            max-height: 80vh;
            padding: 32px;
            box-shadow: var(--shadow-lg);
            transform: translateY(20px) scale(0.95);
            transition: all var(--transition-normal);
            overflow-y: auto;
            border: 1px solid var(--border-light);
        }

        .feedback-modal.active .feedback-container {
            transform: translateY(0) scale(1);
        }

        .feedback-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 24px;
            padding-bottom: 16px;
            border-bottom: 1px solid var(--border-light);
        }

        .feedback-title {
            font-size: 24px;
            font-weight: 700;
            color: var(--text-primary);
        }

        .close-feedback {
            background: none;
            border: none;
            color: var(--text-tertiary);
            font-size: 20px;
            cursor: pointer;
            transition: all var(--transition-fast);
            width: 36px;
            height: 36px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .close-feedback:hover {
            color: var(--text-primary);
            background: var(--bg-tertiary);
        }

        .feedback-form {
            display: flex;
            flex-direction: column;
            gap: 20px;
        }

        .form-group {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .form-label {
            font-weight: 600;
            color: var(--text-primary);
            font-size: 15px;
        }

        .form-input,
        .form-textarea {
            padding: 12px 16px;
            border-radius: var(--border-radius-md);
            border: 1.5px solid var(--border-light);
            background: var(--bg-primary);
            color: var(--text-primary);
            font-size: 15px;
            transition: all var(--transition-fast);
            resize: vertical;
        }

        .form-input:focus,
        .form-textarea:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(255, 45, 85, 0.1);
            outline: none;
        }

        .form-textarea {
            min-height: 120px;
        }

        .feedback-actions {
            display: flex;
            justify-content: flex-end;
            gap: 12px;
            margin-top: 16px;
        }

        .feedback-submit-btn,
        .feedback-cancel-btn {
            border: none;
            border-radius: var(--border-radius-md);
            padding: 12px 24px;
            font-weight: 600;
            cursor: pointer;
            transition: all var(--transition-fast);
            font-size: 15px;
        }

        .feedback-submit-btn {
            background: var(--primary);
            color: var(--text-white);
        }

        .feedback-submit-btn:hover {
            background: var(--primary-light);
            transform: translateY(-2px);
        }

        .feedback-cancel-btn {
            background: var(--bg-tertiary);
            color: var(--text-primary);
        }

        .feedback-cancel-btn:hover {
            background: var(--border-light);
            transform: translateY(-2px);
        }

        /* ===== 动画效果 ===== */
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }

        @keyframes slideInUp {
            from { transform: translateY(20px); opacity: 0; }
            to { transform: translateY(0); opacity: 1; }
        }

        @keyframes pulse {
            0% { transform: scale(1); }
            50% { transform: scale(1.05); }
            100% { transform: scale(1); }
        }

        .fade-in {
            animation: fadeIn 0.5s ease;
        }

        .slide-in-up {
            animation: slideInUp 0.5s ease;
        }

        .pulse {
            animation: pulse 2s infinite;
        }

        /* ===== 付费歌曲提示 ===== */
        .paid-song-indicator {
            background: var(--warning);
            color: var(--text-white);
            font-size: 11px;
            padding: 2px 6px;
            border-radius: 4px;
            margin-left: 6px;
            font-weight: 600;
        }

        .paid-song-loading {
            display: flex;
            align-items: center;
            gap: 8px;
            color: var(--warning);
            font-size: 13px;
            margin-top: 4px;
        }

        /* ===== 整点报时样式 ===== */
        .chime-indicator {
            position: fixed;
            top: 80px;
            right: 24px;
            background: var(--primary);
            color: var(--text-white);
            padding: 8px 16px;
            border-radius: var(--border-radius-md);
            z-index: 1001;
            box-shadow: var(--shadow-md);
            display: none;
            align-items: center;
            gap: 8px;
            font-weight: 500;
            animation: slideInUp 0.5s ease;
        }

        .chime-indicator.show {
            display: flex;
        }

        .chime-settings-group {
            background: var(--bg-tertiary);
            border-radius: var(--border-radius-md);
            padding: 16px;
            margin-bottom: 20px;
        }

        .chime-test-buttons {
            display: flex;
            gap: 12px;
            flex-wrap: wrap;
            margin-top: 16px;
        }

        .chime-test-btn {
            background: var(--bg-card);
            border: 1px solid var(--border-light);
            color: var(--text-primary);
            padding: 8px 16px;
            border-radius: var(--border-radius-md);
            cursor: pointer;
            transition: all var(--transition-fast);
            font-size: 14px;
            font-weight: 500;
        }

        .chime-test-btn:hover {
            background: var(--primary);
            color: var(--text-white);
            transform: translateY(-2px);
        }

        /* ===== API选择器样式 ===== */
        .api-selector {
            display: flex;
            gap: 8px;
            background: var(--bg-tertiary);
            padding: 6px;
            border-radius: var(--border-radius-md);
            flex-wrap: wrap;
            margin-bottom: 16px;
        }

        .api-btn {
            background: transparent;
            border: none;
            color: var(--text-secondary);
            padding: 8px 16px;
            border-radius: var(--border-radius-sm);
            cursor: pointer;
            transition: all var(--transition-fast);
            font-size: 14px;
            font-weight: 500;
        }

        .api-btn.active {
            background: var(--bg-card);
            color: var(--text-primary);
            box-shadow: var(--shadow-sm);
        }

        .api-btn:hover:not(.active) {
            color: var(--text-primary);
        }

        .api-status {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 13px;
            color: var(--text-secondary);
            margin-top: 8px;
        }

        .api-status-indicator {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: var(--success);
        }

        .api-status-indicator.offline {
            background: var(--error);
        }

        /* ===== 抖音/汽水音乐API样式 ===== */
        .api-source-selector {
            display: flex;
            gap: 8px;
            background: var(--bg-tertiary);
            padding: 6px;
            border-radius: var(--border-radius-md);
            flex-wrap: wrap;
            margin-bottom: 16px;
        }

        .api-source-btn {
            background: transparent;
            border: none;
            color: var(--text-secondary);
            padding: 8px 16px;
            border-radius: var(--border-radius-sm);
            cursor: pointer;
            transition: all var(--transition-fast);
            font-size: 14px;
            font-weight: 500;
        }

        .api-source-btn.active {
            background: var(--bg-card);
            color: var(--text-primary);
            box-shadow: var(--shadow-sm);
        }

        .api-source-btn:hover:not(.active) {
            color: var(--text-primary);
        }

        /* ===== 抖音热榜样式 ===== */
        .douyin-hot-section {
            background: var(--bg-card);
            border-radius: var(--border-radius-lg);
            padding: 24px;
            margin-top: 24px;
            border: 1px solid var(--border-light);
            box-shadow: var(--shadow-sm);
        }

        .douyin-hot-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 24px;
            flex-wrap: wrap;
            gap: 16px;
        }

        .douyin-hot-title {
            font-size: 20px;
            font-weight: 700;
            color: var(--text-primary);
        }

        .refresh-douyin-hot {
            background: var(--primary);
            color: var(--text-white);
            border: none;
            padding: 8px 16px;
            border-radius: var(--border-radius-md);
            cursor: pointer;
            transition: all var(--transition-fast);
            font-size: 14px;
            font-weight: 500;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .refresh-douyin-hot:hover {
            background: var(--primary-light);
            transform: translateY(-2px);
        }

        /* ===== 响应式设计 ===== */
        @media (max-width: 1200px) {
            .cards-grid {
                grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
            }
            
            .player-controls {
                max-width: 400px;
            }
        }

        @media (max-width: 992px) {
            .sidebar {
                transform: translateX(-100%);
                width: 300px;
                box-shadow: var(--shadow-lg);
            }

            .sidebar.active {
                transform: translateX(0);
            }

            .mobile-menu-toggle {
                display: flex;
            }

            .content {
                margin-left: 0;
                padding: 20px;
            }

            .search-container {
                width: 300px;
            }

            .player-song-info {
                flex: 0 0 160px;
            }

            .player-extra {
                flex: 0 0 160px;
            }

            .lyrics-panel {
                width: 100%;
                right: -100%;
            }

            .upnext-panel {
                width: 100%;
                right: -100%;
            }

            .welcome-banner {
                flex-direction: column;
                gap: 20px;
                text-align: center;
                padding: 24px;
            }

            .playlist-header {
                flex-direction: column;
                align-items: flex-start;
                gap: 16px;
            }

            .source-selector {
                display: none;
            }

            .admin-content {
                flex-direction: column;
            }

            .admin-sidebar {
                width: 100%;
                flex-direction: row;
                overflow-x: auto;
            }

            .admin-tab {
                flex-shrink: 0;
            }

            .chime-indicator {
                top: 70px;
                right: 16px;
                left: 16px;
                justify-content: center;
            }

            .douyin-hot-header {
                flex-direction: column;
                align-items: flex-start;
            }
        }

        @media (max-width: 768px) {
            .cards-grid {
                grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
                gap: 16px;
            }

            .search-container {
                width: 250px;
            }

            .player {
                padding: 0 16px;
            }

            .player-song-info {
                flex: 0 0 120px;
            }

            .player-extra {
                flex: 0 0 120px;
            }

            .volume-slider {
                width: 60px;
            }

            .lyrics-panel {
                padding: 20px;
            }

            .lyrics-album-art {
                width: 160px;
                height: 160px;
            }

            .upnext-panel {
                padding: 20px;
            }

            .fullscreen-content {
                padding: 24px;
                gap: 32px;
            }

            .fullscreen-album-art {
                width: 240px;
                height: 240px;
            }

            .fullscreen-title {
                font-size: 24px;
            }

            .fullscreen-artist {
                font-size: 18px;
            }

            .fullscreen-controls {
                gap: 16px;
            }

            .fullscreen-control-btn {
                width: 48px;
                height: 48px;
                font-size: 18px;
            }

            .fullscreen-play-btn {
                width: 56px;
                height: 56px;
                font-size: 20px;
            }

            .mobile-controls {
                display: flex;
            }

            .admin-header {
                padding: 16px 20px;
            }

            .admin-content {
                padding: 16px;
            }

            .admin-main {
                padding: 20px;
            }

            .feedback-container {
                padding: 24px;
            }

            .chime-test-buttons {
                flex-direction: column;
            }

            .api-selector {
                flex-direction: column;
            }

            .api-source-selector {
                flex-direction: column;
            }

            .douyin-hot-header {
                flex-direction: column;
                align-items: stretch;
            }

            .refresh-douyin-hot {
                width: 100%;
                justify-content: center;
            }
        }

        @media (max-width: 576px) {
            .cards-grid {
                grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
                gap: 12px;
            }

            .search-container {
                width: 200px;
            }

            .content {
                padding: 16px;
            }

            .section-title {
                margin: 32px 0 20px;
            }

            .section-title h2 {
                font-size: 20px;
            }

            .player-album-art {
                width: 48px;
                height: 48px;
                margin-right: 12px;
            }

            .player-song-info {
                flex: 0 0 100px;
                margin-right: 16px;
            }

            .player-extra {
                flex: 0 0 80px;
            }

            .volume-container {
                display: none;
            }

            .toggle-lyrics {
                display: none;
            }

            .upnext-toggle {
                display: none;
            }

            .player-buttons {
                gap: 16px;
            }

            .lyrics-panel {
                padding: 16px;
            }

            .lyrics-album-art {
                width: 120px;
                height: 120px;
            }

            .lyrics-song-title {
                font-size: 18px;
            }

            .lyrics-song-artist {
                font-size: 14px;
            }

            .lyrics-container {
                font-size: 16px;
                line-height: 2;
            }

            .current-lyric {
                font-size: 18px;
            }

            .upnext-panel {
                padding: 16px;
            }

            .upnext-actions {
                flex-direction: column;
            }

            .fullscreen-content {
                padding: 20px;
                gap: 24px;
            }

            .fullscreen-album-art {
                width: 200px;
                height: 200px;
            }

            .fullscreen-title {
                font-size: 20px;
            }

            .fullscreen-artist {
                font-size: 16px;
            }

            .fullscreen-lyrics {
                font-size: 16px;
                line-height: 1.8;
            }

            .fullscreen-controls {
                gap: 12px;
            }

            .fullscreen-control-btn {
                width: 44px;
                height: 44px;
                font-size: 16px;
            }

            .fullscreen-play-btn {
                width: 52px;
                height: 52px;
                font-size: 18px;
            }

            .download-container {
                padding: 24px;
            }

            .download-actions {
                flex-direction: column;
            }

            .download-confirm-btn,
            .download-cancel-btn {
                width: 100%;
            }

            .admin-sidebar {
                flex-direction: column;
            }

            .feedback-actions {
                flex-direction: column;
            }

            .feedback-submit-btn,
            .feedback-cancel-btn {
                width: 100%;
            }

            .douyin-hot-section {
                padding: 16px;
            }
        }

        @media (max-width: 400px) {
            .search-container {
                width: 160px;
            }
            
            .cards-grid {
                grid-template-columns: repeat(2, 1fr);
            }
            
            .player-controls {
                max-width: 200px;
            }
            
            .player-buttons {
                gap: 12px;
            }
        }
    </style>
</head>
<body>
    <!-- 整点报时指示器 -->
    <div class="chime-indicator" id="chimeIndicator">
        <i class="fas fa-bell"></i>
        <span id="chimeText">整点报时</span>
    </div>

    <!-- 下载模态框 -->
    <div class="download-modal" id="downloadModal">
        <div class="download-container">
            <div class="download-header">
                <div class="download-title">下载选项</div>
                <button class="close-download" id="closeDownload">
                    <i class="fas fa-times"></i>
                </button>
            </div>
            <div class="download-options">
                <div class="download-option">
                    <input type="checkbox" id="downloadAudio" checked>
                    <label for="downloadAudio">下载音频</label>
                    <div class="download-format-group">
                        <div class="format-group-title">音频格式:</div>
                        <div class="download-format-options">
                            <div class="download-format-option">
                                <input type="radio" id="audioFormatMp3" name="audioFormat" value="mp3" checked>
                                <label for="audioFormatMp3">MP3</label>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="download-option">
                    <input type="checkbox" id="downloadAlbumArt" checked>
                    <label for="downloadAlbumArt">下载专辑封面</label>
                </div>
                <div class="download-option">
                    <input type="checkbox" id="downloadLyrics" checked>
                    <label for="downloadLyrics">下载歌词</label>
                    <div class="download-format-group">
                        <div class="format-group-title">歌词格式:</div>
                        <div class="download-format-options">
                            <div class="download-format-option">
                                <input type="radio" id="lyricsFormatLrc" name="lyricsFormat" value="lrc" checked>
                                <label for="lyricsFormatLrc">LRC</label>
                            </div>
                            <div class="download-format-option">
                                <input type="radio" id="lyricsFormatTxt" name="lyricsFormat" value="txt">
                                <label for="lyricsFormatTxt">TXT</label>
                            </div>
                            <div class="download-format-option">
                                <input type="radio" id="lyricsFormatWord" name="lyricsFormat" value="word">
                                <label for="lyricsFormatWord">Word</label>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="download-actions">
                <button class="download-cancel-btn" id="downloadCancelBtn">取消</button>
                <button class="download-confirm-btn" id="downloadConfirmBtn">开始下载</button>
            </div>
        </div>
    </div>

    <!-- 意见反馈模态框 -->
    <div class="feedback-modal" id="feedbackModal">
        <div class="feedback-container">
            <div class="feedback-header">
                <div class="feedback-title">意见反馈</div>
                <button class="close-feedback" id="closeFeedbackBtn">
                    <i class="fas fa-times"></i>
                </button>
            </div>
            <form class="feedback-form" id="feedbackForm">
                <div class="form-group">
                    <label class="form-label" for="feedbackEmail">邮箱地址</label>
                    <input type="email" class="form-input" id="feedbackEmail" placeholder="请输入您的邮箱" required>
                </div>
                <div class="form-group">
                    <label class="form-label" for="feedbackContent">反馈内容</label>
                    <textarea class="form-textarea" id="feedbackContent" placeholder="请输入您的宝贵意见或建议..." required></textarea>
                </div>
                <div class="feedback-actions">
                    <button type="button" class="feedback-cancel-btn" id="feedbackCancelBtn">取消</button>
                    <button type="submit" class="feedback-submit-btn">提交反馈</button>
                </div>
            </form>
        </div>
    </div>

    <!-- 后台管理面板 -->
    <div class="admin-panel" id="adminPanel">
        <div class="admin-header">
            <div class="admin-title">后台管理系统</div>
            <button class="admin-close" id="adminCloseBtn">
                <i class="fas fa-times"></i>
            </button>
        </div>
        <div class="admin-content">
            <div class="admin-sidebar">
                <div class="admin-tab active" data-tab="feedback">用户反馈</div>
                <div class="admin-tab" data-tab="userData">用户数据</div>
                <div class="admin-tab" data-tab="system">系统设置</div>
                <div class="admin-tab" data-tab="chimeSettings">整点报时</div>
                <div class="admin-tab" data-tab="apiSettings">API设置</div>
            </div>
            <div class="admin-main">
                <div class="admin-section active" id="feedbackSection">
                    <h2 class="section-title">用户反馈</h2>
                    <div class="feedback-list" id="adminFeedbackList">
                        <!-- 反馈列表将在这里动态生成 -->
                    </div>
                    <div class="admin-actions">
                        <button class="admin-btn secondary" id="exportFeedbackBtn">
                            <i class="fas fa-download"></i> 导出反馈
                        </button>
                        <button class="admin-btn secondary" id="clearFeedbackBtn">
                            <i class="fas fa-trash"></i> 清空反馈
                        </button>
                    </div>
                </div>
                <div class="admin-section" id="userDataSection">
                    <h2 class="section-title">用户数据</h2>
                    <div class="user-data-list" id="adminUserDataList">
                        <!-- 用户数据列表将在这里动态生成 -->
                    </div>
                    <div class="admin-actions">
                        <button class="admin-btn primary" id="uploadUserDataBtn">
                            <i class="fas fa-cloud-upload-alt"></i> 上传用户数据
                        </button>
                        <button class="admin-btn secondary" id="exportUserDataBtn">
                            <i class="fas fa-download"></i> 导出数据
                        </button>
                    </div>
                </div>
                <div class="admin-section" id="systemSection">
                    <h2 class="section-title">系统设置</h2>
                    <div class="form-group">
                        <label class="form-label" for="autoUploadInterval">自动上传间隔 (分钟)</label>
                        <input type="number" class="form-input" id="autoUploadInterval" value="5" min="1" max="60">
                    </div>
                    <div class="form-group">
                        <label class="form-label" for="maxFeedbackItems">最大反馈数量</label>
                        <input type="number" class="form-input" id="maxFeedbackItems" value="100" min="10" max="1000">
                    </div>
                    <div class="admin-actions">
                        <button class="admin-btn primary" id="saveSettingsBtn">
                            <i class="fas fa-save"></i> 保存设置
                        </button>
                        <button class="admin-btn secondary" id="resetSettingsBtn">
                            <i class="fas fa-undo"></i> 恢复默认
                        </button>
                    </div>
                </div>
                <div class="admin-section" id="chimeSettingsSection">
                    <h2 class="section-title">整点报时设置</h2>
                    <div class="chime-settings-group">
                        <div class="form-group">
                            <label class="form-label" for="chimeEnabled">启用整点报时</label>
                            <input type="checkbox" id="chimeEnabled" checked>
                        </div>
                        <div class="form-group">
                            <label class="form-label" for="chimeVolume">报时音量</label>
                            <input type="range" class="form-input" id="chimeVolume" min="0" max="100" value="50">
                            <span id="chimeVolumeValue">50%</span>
                        </div>
                        <div class="form-group">
                            <label class="form-label" for="chimeStartTime">开始时间</label>
                            <input type="time" class="form-input" id="chimeStartTime" value="08:00">
                        </div>
                        <div class="form-group">
                            <label class="form-label" for="chimeEndTime">结束时间</label>
                            <input type="time" class="form-input" id="chimeEndTime" value="22:00">
                        </div>
                        <div class="form-group">
                            <label class="form-label">测试报时功能</label>
                            <div class="chime-test-buttons">
                                <button class="chime-test-btn" id="testChime1">测试整点报时 (当前时间)</button>
                                <button class="chime-test-btn" id="testChime2">测试整点报时 (自定义时间)</button>
                                <button class="chime-test-btn" id="testChime3">测试报时音量</button>
                            </div>
                        </div>
                    </div>
                    <div class="admin-actions">
                        <button class="admin-btn primary" id="saveChimeSettingsBtn">
                            <i class="fas fa-save"></i> 保存设置
                        </button>
                        <button class="admin-btn secondary" id="resetChimeSettingsBtn">
                            <i class="fas fa-undo"></i> 恢复默认
                        </button>
                    </div>
                </div>
                <div class="admin-section" id="apiSettingsSection">
                    <h2 class="section-title">API设置</h2>
                    <div class="form-group">
                        <label class="form-label">选择音乐API</label>
                        <div class="api-selector">
                            <button class="api-btn active" data-api="main">主用API (网易云官方)</button>
                            <button class="api-btn" data-api="backup">备用API (GD Studio)</button>
                            <button class="api-btn" data-api="douyin">抖音点歌</button>
                            <button class="api-btn" data-api="qishui">汽水音乐</button>
                        </div>
                        <div class="api-status">
                            <div class="api-status-indicator" id="apiStatusIndicator"></div>
                            <span id="apiStatusText">主用API - 网易云官方API</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="form-label" for="apiTestQuery">API测试</label>
                        <div class="search-container" style="width: 100%; margin-bottom: 12px;">
                            <i class="fas fa-search"></i>
                            <input type="text" id="apiTestQuery" placeholder="输入歌曲名测试API..." value="周杰伦">
                        </div>
                        <button class="admin-btn secondary" id="testApiBtn" style="width: 100%;">
                            <i class="fas fa-bolt"></i> 测试当前API
                        </button>
                    </div>
                    <div class="form-group">
                        <label class="form-label">API信息</label>
                        <div class="chime-settings-group">
                            <p><strong>主用API:</strong> 网易云官方API</p>
                            <p><strong>备用API:</strong> GD Studio's Online Music Platform API</p>
                            <p><strong>抖音点歌:</strong> 抖音音乐API</p>
                            <p><strong>汽水音乐:</strong> 汽水音乐API，付费歌曲自动切换</p>
                            <p><strong>当前限制:</strong> 5分钟内不超过60次请求</p>
                            <p><strong>音乐源:</strong> 网易云音乐、抖音音乐、汽水音乐</p>
                        </div>
                    </div>
                    <div class="admin-actions">
                        <button class="admin-btn primary" id="saveApiSettingsBtn">
                            <i class="fas fa-save"></i> 保存设置
                        </button>
                        <button class="admin-btn secondary" id="resetApiSettingsBtn">
                            <i class="fas fa-undo"></i> 恢复默认
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 移动端菜单切换按钮 -->
    <button class="mobile-menu-toggle" id="mobileMenuToggle">
        <i class="fas fa-bars"></i>
    </button>

    <!-- 侧边栏 -->
    <div class="sidebar" id="sidebar">
        <div class="logo" id="logo">
            <i class="fas fa-music"></i>
            <span>悦音阁</span>
        </div>

        <div class="nav-section">
            <div class="nav-title">导航</div>
            <ul class="nav-links">
                <li><a href="#" class="active" id="homeLink"><i class="fas fa-home"></i> 首页</a></li>
                <li><a href="#" id="searchLink"><i class="fas fa-search"></i> 搜索</a></li>
                <li><a href="#" id="myMusicLibraryLink"><i class="fas fa-layer-group"></i> 我的音乐库</a></li>
                <li><a href="#" id="downloadsLink"><i class="fas fa-download"></i> 下载管理</a></li>
                <li><a href="#" id="settingsLink"><i class="fas fa-cog"></i> 设置</a></li>
                <li><a href="#" id="feedbackLink"><i class="fas fa-comment-alt"></i> 意见反馈</a></li>
            </ul>
        </div>

        <div class="nav-section">
            <div class="nav-title">你的音乐库</div>
            <ul class="nav-links">
                <li><a href="#" id="favoriteMusicLink"><i class="fas fa-heart"></i> 我喜欢的音乐</a></li>
                <li><a href="#" id="playHistoryLink"><i class="fas fa-history"></i> 播放历史</a></li>
                <li><a href="#" id="downloadManagementLink"><i class="fas fa-download"></i> 下载管理</a></li>
                <li><a href="#" id="upNextLink"><i class="fas fa-list"></i> 待播放列表</a></li>
            </ul>
        </div>

        <div class="nav-section">
            <div class="nav-title">热门歌单</div>
            <ul class="nav-links">
                <li><a href="#" id="hotPlaylistLink1"><i class="fas fa-fire"></i> 热歌榜</a></li>
                <li><a href="#" id="hotPlaylistLink2"><i class="fas fa-star"></i> 新歌榜</a></li>
                <li><a href="#" id="hotPlaylistLink3"><i class="fas fa-chart-line"></i> 飙升榜</a></li>
                <li><a href="#" id="hotPlaylistLink4"><i class="fas fa-pen-fancy"></i> 原创榜</a></li>
                <li><a href="#" id="douyinHotLink"><i class="fab fa-tiktok"></i> 抖音热榜</a></li>
            </ul>
        </div>
    </div>

    <!-- 移动端控制按钮 -->
    <div class="mobile-controls" id="mobileControls">
        <button class="mobile-control-btn" id="mobilePrevBtn">
            <i class="fas fa-step-backward"></i>
        </button>
        <button class="mobile-control-btn" id="mobilePlayBtn">
            <i class="fas fa-play"></i>
        </button>
        <button class="mobile-control-btn" id="mobileNextBtn">
            <i class="fas fa-step-forward"></i>
        </button>
        <button class="mobile-control-btn" id="mobileLyricsBtn">
            <i class="fas fa-microphone"></i>
        </button>
        <button class="mobile-control-btn" id="mobileFavoriteBtn">
            <i class="fas fa-heart"></i>
        </button>
    </div>

    <!-- 主内容区 -->
    <div class="content">
        <!-- 顶部导航 -->
        <div class="top-nav">
            <div class="search-container">
                <i class="fas fa-search"></i>
                <input type="text" id="searchInput" placeholder="搜索歌曲、歌手..." autocomplete="off">
                <div class="search-suggestions" id="searchSuggestions">
                    <!-- 搜索建议将在这里动态生成 -->
                </div>
                <div class="search-history" id="searchHistory">
                    <div class="search-history-header">
                        <span>搜索历史</span>
                        <button id="clearSearchHistory">清空</button>
                    </div>
                    <div class="search-history-list" id="searchHistoryList">
                        <!-- 搜索历史将在这里动态生成 -->
                    </div>
                </div>
            </div>

            <div class="user-actions">
                <button class="theme-toggle" id="themeToggleBtn">
                    <i class="fas fa-moon"></i>
                </button>
            </div>
        </div>

        <!-- API选择器 -->
        <div class="api-selector" id="apiSelector">
            <button class="api-btn active" data-api="main">主用API</button>
            <button class="api-btn" data-api="backup">备用API</button>
            <button class="api-btn" data-api="douyin">抖音点歌</button>
            <button class="api-btn" data-api="qishui">汽水音乐</button>
        </div>
        <div class="api-status">
            <div class="api-status-indicator" id="mainApiStatusIndicator"></div>
            <span id="apiStatusText">当前使用: 主用API (网易云官方)</span>
        </div>

        <!-- 欢迎横幅 -->
        <div class="welcome-banner">
            <div class="welcome-text">
                <h1 id="welcomeTitle">晚上好，音乐爱好者</h1>
                <p id="welcomeSubtitle">让音乐点亮你的生活，发现更多精彩内容</p>
            </div>
            <button class="play-shuffle-btn" id="playShuffleBtn">
                <i class="fas fa-random"></i> 随机播放
            </button>
        </div>

        <!-- 榜单推荐 -->
        <div class="section-title">
            <h2>热门榜单</h2>
            <a href="#" class="see-all" id="refreshChartsBtn">刷新榜单</a>
        </div>

        <div class="cards-grid" id="chartsGrid">
            <!-- 榜单将通过JavaScript动态生成 -->
        </div>

        <!-- 抖音热榜 -->
        <div class="douyin-hot-section">
            <div class="douyin-hot-header">
                <div class="douyin-hot-title">抖音热榜</div>
                <button class="refresh-douyin-hot" id="refreshDouyinHotBtn">
                    <i class="fas fa-sync-alt"></i> 刷新热榜
                </button>
            </div>

            <div class="song-list" id="douyinHotList">
                <div class="loading" id="douyinHotLoading">
                    <i class="fas fa-spinner"></i>
                    <span>加载抖音热榜中...</span>
                </div>
            </div>
        </div>

        <!-- 热榜歌单 -->
        <div class="section-title">
            <h2>热榜推荐</h2>
            <a href="#" class="see-all">显示全部</a>
        </div>

        <div class="cards-grid" id="hotPlaylist">
            <!-- 热榜歌单将通过JavaScript动态生成 -->
        </div>

        <!-- 为你推荐 -->
        <div class="section-title">
            <h2>为你推荐</h2>
            <a href="#" class="see-all">显示全部</a>
        </div>

        <div class="cards-grid">
            <div class="card">
                <div class="card-image">
                    <i class="fas fa-cloud" style="font-size: 48px;"></i>
                </div>
                <div class="card-title">每日推荐</div>
                <div class="card-description">根据你的听歌习惯生成</div>
                <div class="card-play-btn">
                    <i class="fas fa-play"></i>
                </div>
            </div>
            <div class="card">
                <div class="card-image">
                    <i class="fas fa-calendar" style="font-size: 48px;"></i>
                </div>
                <div class="card-title">每周新发现</div>
                <div class="card-description">每周为你推荐新音乐</div>
                <div class="card-play-btn">
                    <i class="fas fa-play"></i>
                </div>
            </div>
            <div class="card">
                <div class="card-image">
                    <i class="fas fa-heart" style="font-size: 48px;"></i>
                </div>
                <div class="card-title">心动模式</div>
                <div class="card-description">混合你喜欢的歌曲</div>
                <div class="card-play-btn">
                    <i class="fas fa-play"></i>
                </div>
            </div>
            <div class="card">
                <div class="card-image">
                    <i class="fas fa-compact-disc" style="font-size: 48px;"></i>
                </div>
                <div class="card-title">专属歌单</div>
                <div class="card-description">为你量身定制的歌单</div>
                <div class="card-play-btn">
                    <i class="fas fa-play"></i>
                </div>
            </div>
        </div>

        <!-- 播放列表 -->
        <div class="playlist-section">
            <div class="playlist-header">
                <div class="playlist-title" id="playlistTitle">推荐歌单</div>
                <div class="source-selector">
                    <button class="source-btn active" data-source="netease">网易云</button>
                </div>
            </div>

            <div class="error-message" id="errorMessage">
                <i class="fas fa-exclamation-circle"></i>
                <span id="errorText">发生错误，请稍后重试</span>
            </div>

            <div class="song-list" id="songList">
                <div class="loading" id="loadingIndicator">
                    <i class="fas fa-spinner"></i>
                    <span>加载中...</span>
                </div>
            </div>
        </div>
    </div>

    <!-- 播放器 -->
    <div class="player">
        <div class="player-album-art" id="playerAlbumArt">
            <img src="" alt="专辑封面">
        </div>
        <div class="player-song-info">
            <div class="player-song-title">选择一首歌曲开始播放</div>
            <div class="player-song-artist">-</div>
        </div>
        <div class="player-controls">
            <div class="player-buttons">
                <button class="control-btn" id="shuffleBtn">
                    <i class="fas fa-random"></i>
                </button>
                <button class="control-btn" id="prevBtn">
                    <i class="fas fa-step-backward"></i>
                </button>
                <button class="control-btn play-btn" id="playBtn">
                    <i class="fas fa-play"></i>
                </button>
                <button class="control-btn" id="nextBtn">
                    <i class="fas fa-step-forward"></i>
                </button>
                <button class="control-btn" id="repeatBtn">
                    <i class="fas fa-redo"></i>
                </button>
            </div>
            <div class="player-progress">
                <div class="player-time" id="currentTime">--:--</div>
                <div class="progress-bar" id="progressBar">
                    <div class="progress" id="progress"></div>
                </div>
                <div class="player-time" id="duration">--:--</div>
            </div>
        </div>
        <div class="player-extra">
            <button class="control-btn upnext-toggle" id="upNextToggleBtn">
                <i class="fas fa-list"></i>
            </button>
            <button class="control-btn toggle-lyrics" id="toggleLyricsBtn">
                <i class="fas fa-microphone"></i>
            </button>
            <button class="control-btn" id="favoriteBtn">
                <i class="fas fa-heart"></i>
            </button>
            <div class="volume-container">
                <button class="control-btn" id="volumeBtn">
                    <i class="fas fa-volume-up"></i>
                </button>
                <input type="range" class="volume-slider" id="volumeSlider" min="0" max="100" value="80">
            </div>
            <button class="control-btn" id="fullscreenToggleBtn">
                <i class="fas fa-expand"></i>
            </button>
        </div>
    </div>

    <!-- 歌词面板 -->
    <div class="lyrics-panel" id="lyricsPanel">
        <div class="lyrics-header">
            <div class="lyrics-title">歌词</div>
            <button class="close-lyrics" id="closeLyricsBtn">
                <i class="fas fa-times"></i>
            </button>
        </div>
        
        <div class="lyrics-album-section">
            <div class="lyrics-album-art" id="lyricsAlbumArt">
                <img src="" alt="专辑封面">
            </div>
            <div class="lyrics-song-info">
                <div class="lyrics-song-title" id="lyricsSongTitle">选择一首歌曲开始播放</div>
                <div class="lyrics-song-artist" id="lyricsSongArtist">-</div>
            </div>
        </div>
        
        <div class="lyrics-container" id="lyricsContainer">
            <div class="no-lyrics">
                <i class="fas fa-music"></i>
                <div>暂无歌词</div>
            </div>
        </div>
    </div>

    <!-- 待播放列表面板 -->
    <div class="upnext-panel" id="upNextPanel">
        <div class="upnext-header">
            <div class="upnext-title">待播放列表</div>
            <button class="close-upnext" id="closeUpNextBtn">
                <i class="fas fa-times"></i>
            </button>
        </div>
        
        <div class="upnext-actions">
            <button class="upnext-action-btn" id="clearUpNextBtn">
                <i class="fas fa-trash"></i> 清空列表
            </button>
            <button class="upnext-action-btn" id="shuffleUpNextBtn">
                <i class="fas fa-random"></i> 随机播放
            </button>
        </div>
        
        <div class="upnext-list" id="upNextList">
            <div class="upnext-empty">
                <i class="fas fa-list"></i>
                <p>待播放列表为空</p>
                <p>点击歌曲的"添加到待播放列表"按钮来添加歌曲</p>
            </div>
        </div>
    </div>

    <!-- 全屏模式 -->
    <div class="fullscreen-overlay" id="fullscreenOverlay">
        <div class="fullscreen-header">
            <div class="fullscreen-title" id="fullscreenTitle">选择一首歌曲开始播放</div>
            <button class="fullscreen-exit" id="fullscreenExitBtn">
                <i class="fas fa-times"></i>
            </button>
        </div>
        
        <div class="fullscreen-content">
            <div class="fullscreen-album-art" id="fullscreenAlbumArt">
                <img src="" alt="专辑封面">
            </div>
            <div class="fullscreen-info">
                <div class="fullscreen-artist" id="fullscreenArtist">-</div>
                <div class="fullscreen-album" id="fullscreenAlbum">-</div>
            </div>
            <div class="fullscreen-progress">
                <div class="fullscreen-time-info">
                    <span id="fullscreenCurrentTime">--:--</span>
                    <span id="fullscreenDuration">--:--</span>
                </div>
                <div class="fullscreen-progress-bar" id="fullscreenProgressBar">
                    <div class="fullscreen-progress" id="fullscreenProgress"></div>
                </div>
            </div>
            <div class="fullscreen-controls">
                <button class="fullscreen-control-btn" id="fullscreenShuffleBtn">
                    <i class="fas fa-random"></i>
                </button>
                <button class="fullscreen-control-btn" id="fullscreenPrevBtn">
                    <i class="fas fa-step-backward"></i>
                </button>
                <button class="fullscreen-control-btn fullscreen-play-btn" id="fullscreenPlayBtn">
                    <i class="fas fa-play"></i>
                </button>
                <button class="fullscreen-control-btn" id="fullscreenNextBtn">
                    <i class="fas fa-step-forward"></i>
                </button>
                <button class="fullscreen-control-btn" id="fullscreenRepeatBtn">
                    <i class="fas fa-redo"></i>
                </button>
                <button class="fullscreen-control-btn fullscreen-favorite-btn" id="fullscreenFavoriteBtn">
                    <i class="fas fa-heart"></i>
                </button>
            </div>
            <div class="fullscreen-lyrics" id="fullscreenLyrics">
                <div class="no-lyrics">
                    <i class="fas fa-music"></i>
                    <div>暂无歌词</div>
                </div>
            </div>
        </div>
    </div>

    <script>
        // 更新日志
        const updateLog = [
            "🎵 悦音阁 v23.0.0 - 多API全面优化版",
            "",
            "✨ 主要更新:",
            "  - 修复主用API音乐播放和封面显示问题",
            "  - 修复备用API音乐播放和封面显示问题", 
            "  - 新增抖音热榜单支持并支持播放",
            "  - 优化移动端UI适配和全屏模式",
            "  - 修复多个已知BUG",
            "  - 增强API错误处理和自动切换",
            "",
            "🔧 API修复:",
            "  - 修复主用API音乐URL获取逻辑",
            "  - 修复备用API专辑封面URL构建",
            "  - 修复抖音点歌API数据处理",
            "  - 修复汽水音乐API付费歌曲处理",
            "  - 优化API响应数据解析",
            "",
            "📱 移动端优化:",
            "  - 改进全屏模式在手机端的显示",
            "  - 优化触摸交互体验",
            "  - 提升移动端控制按钮响应性",
            "  - 适配各种屏幕尺寸",
            "",
            "🎨 UI/UX 改进:",
            "  - 优化播放器控制界面",
            "  - 改进歌词显示效果",
            "  - 提升整体视觉一致性",
            "  - 优化加载状态提示",
            "",
            "⚡ 性能优化:",
            "  - 优化图片加载和缓存机制",
            "  - 减少不必要的DOM操作",
            "  - 改进API请求效率",
            "",
            "🔌 API系统增强:",
            "  - 增强API状态监控和显示",
            "  - 优化API失败时的自动切换",
            "  - 改进错误处理和用户提示",
            "",
            "🎯 新增功能:",
            "  - 抖音热榜单：支持抖音热门音乐播放",
            "  - 多API智能切换：主用API失败时自动使用备用API",
            "  - 增强移动端全屏体验",
            "",
            "🔒 兼容性改进:",
            "  - 适配全平台浏览器兼容性",
            "  - 改进大屏幕显示效果",
            "  - 优化跨设备体验一致性",
            "",
            "📄 更新说明:",
            "  - 修复了API调用参数传递问题",
            "  - 优化了全屏模式在移动端的体验",
            "  - 提升了整体应用的稳定性和性能",
            "  - 改进了用户界面和交互体验",
            "  - 增强了API系统的健壮性"
        ];

        console.log("悦音阁更新日志:");
        updateLog.forEach(log => console.log(log));

        document.addEventListener('DOMContentLoaded', function() {
            // DOM元素引用
            const elements = {
                // 整点报时相关
                chimeIndicator: document.getElementById('chimeIndicator'),
                chimeText: document.getElementById('chimeText'),
                chimeEnabled: document.getElementById('chimeEnabled'),
                chimeVolume: document.getElementById('chimeVolume'),
                chimeVolumeValue: document.getElementById('chimeVolumeValue'),
                chimeStartTime: document.getElementById('chimeStartTime'),
                chimeEndTime: document.getElementById('chimeEndTime'),
                testChime1: document.getElementById('testChime1'),
                testChime2: document.getElementById('testChime2'),
                testChime3: document.getElementById('testChime3'),
                saveChimeSettingsBtn: document.getElementById('saveChimeSettingsBtn'),
                resetChimeSettingsBtn: document.getElementById('resetChimeSettingsBtn'),
                
                // 下载相关
                downloadModal: document.getElementById('downloadModal'),
                closeDownload: document.getElementById('closeDownload'),
                downloadCancelBtn: document.getElementById('downloadCancelBtn'),
                downloadConfirmBtn: document.getElementById('downloadConfirmBtn'),
                downloadAudioCheckbox: document.getElementById('downloadAudio'),
                downloadAlbumArtCheckbox: document.getElementById('downloadAlbumArt'),
                downloadLyricsCheckbox: document.getElementById('downloadLyrics'),
                audioFormatRadios: document.querySelectorAll('input[name="audioFormat"]'),
                lyricsFormatRadios: document.querySelectorAll('input[name="lyricsFormat"]'),
                
                // 意见反馈相关
                feedbackModal: document.getElementById('feedbackModal'),
                closeFeedbackBtn: document.getElementById('closeFeedbackBtn'),
                feedbackCancelBtn: document.getElementById('feedbackCancelBtn'),
                feedbackForm: document.getElementById('feedbackForm'),
                feedbackEmail: document.getElementById('feedbackEmail'),
                feedbackContent: document.getElementById('feedbackContent'),
                feedbackLink: document.getElementById('feedbackLink'),
                
                // 后台管理相关
                adminPanel: document.getElementById('adminPanel'),
                adminCloseBtn: document.getElementById('adminCloseBtn'),
                adminTabs: document.querySelectorAll('.admin-tab'),
                adminSections: document.querySelectorAll('.admin-section'),
                adminFeedbackList: document.getElementById('adminFeedbackList'),
                adminUserDataList: document.getElementById('adminUserDataList'),
                exportFeedbackBtn: document.getElementById('exportFeedbackBtn'),
                clearFeedbackBtn: document.getElementById('clearFeedbackBtn'),
                uploadUserDataBtn: document.getElementById('uploadUserDataBtn'),
                exportUserDataBtn: document.getElementById('exportUserDataBtn'),
                autoUploadInterval: document.getElementById('autoUploadInterval'),
                maxFeedbackItems: document.getElementById('maxFeedbackItems'),
                saveSettingsBtn: document.getElementById('saveSettingsBtn'),
                resetSettingsBtn: document.getElementById('resetSettingsBtn'),
                logo: document.getElementById('logo'),
                
                // API相关
                apiSelector: document.getElementById('apiSelector'),
                apiBtns: document.querySelectorAll('.api-btn'),
                mainApiStatusIndicator: document.getElementById('mainApiStatusIndicator'),
                apiStatusText: document.getElementById('apiStatusText'),
                apiStatusIndicator: document.getElementById('apiStatusIndicator'),
                apiTestQuery: document.getElementById('apiTestQuery'),
                testApiBtn: document.getElementById('testApiBtn'),
                saveApiSettingsBtn: document.getElementById('saveApiSettingsBtn'),
                resetApiSettingsBtn: document.getElementById('resetApiSettingsBtn'),
                
                // 待播放列表相关
                upNextPanel: document.getElementById('upNextPanel'),
                upNextToggleBtn: document.getElementById('upNextToggleBtn'),
                closeUpNextBtn: document.getElementById('closeUpNextBtn'),
                upNextList: document.getElementById('upNextList'),
                clearUpNextBtn: document.getElementById('clearUpNextBtn'),
                shuffleUpNextBtn: document.getElementById('shuffleUpNextBtn'),
                upNextLink: document.getElementById('upNextLink'),
                
                // 布局相关
                mobileMenuToggle: document.getElementById('mobileMenuToggle'),
                sidebar: document.getElementById('sidebar'),
                content: document.querySelector('.content'),
                
                // 搜索相关
                searchInput: document.getElementById('searchInput'),
                searchSuggestions: document.getElementById('searchSuggestions'),
                searchHistory: document.getElementById('searchHistory'),
                searchHistoryList: document.getElementById('searchHistoryList'),
                clearSearchHistory: document.getElementById('clearSearchHistory'),
                
                // 播放列表
                songList: document.getElementById('songList'),
                playlistTitle: document.getElementById('playlistTitle'),
                loadingIndicator: document.getElementById('loadingIndicator'),
                errorMessage: document.getElementById('errorMessage'),
                errorText: document.getElementById('errorText'),
                
                // 播放控制
                playBtn: document.getElementById('playBtn'),
                prevBtn: document.getElementById('prevBtn'),
                nextBtn: document.getElementById('nextBtn'),
                shuffleBtn: document.getElementById('shuffleBtn'),
                repeatBtn: document.getElementById('repeatBtn'),
                progressBar: document.getElementById('progressBar'),
                progress: document.getElementById('progress'),
                currentTime: document.getElementById('currentTime'),
                duration: document.getElementById('duration'),
                playShuffleBtn: document.getElementById('playShuffleBtn'),
                
                // 收藏功能
                favoriteBtn: document.getElementById('favoriteBtn'),
                mobileFavoriteBtn: document.getElementById('mobileFavoriteBtn'),
                fullscreenFavoriteBtn: document.getElementById('fullscreenFavoriteBtn'),
                
                // 音量控制
                volumeBtn: document.getElementById('volumeBtn'),
                volumeSlider: document.getElementById('volumeSlider'),
                
                // 歌词面板
                toggleLyricsBtn: document.getElementById('toggleLyricsBtn'),
                closeLyricsBtn: document.getElementById('closeLyricsBtn'),
                lyricsPanel: document.getElementById('lyricsPanel'),
                lyricsContainer: document.getElementById('lyricsContainer'),
                lyricsAlbumArt: document.getElementById('lyricsAlbumArt'),
                lyricsSongTitle: document.getElementById('lyricsSongTitle'),
                lyricsSongArtist: document.getElementById('lyricsSongArtist'),
                
                // 主题切换
                themeToggleBtn: document.getElementById('themeToggleBtn'),
                
                // 移动端控制
                mobileControls: document.getElementById('mobileControls'),
                mobilePrevBtn: document.getElementById('mobilePrevBtn'),
                mobilePlayBtn: document.getElementById('mobilePlayBtn'),
                mobileNextBtn: document.getElementById('mobileNextBtn'),
                mobileLyricsBtn: document.getElementById('mobileLyricsBtn'),
                
                // 全屏模式
                fullscreenToggleBtn: document.getElementById('fullscreenToggleBtn'),
                fullscreenOverlay: document.getElementById('fullscreenOverlay'),
                fullscreenAlbumArt: document.getElementById('fullscreenAlbumArt'),
                fullscreenTitle: document.getElementById('fullscreenTitle'),
                fullscreenArtist: document.getElementById('fullscreenArtist'),
                fullscreenAlbum: document.getElementById('fullscreenAlbum'),
                fullscreenLyrics: document.getElementById('fullscreenLyrics'),
                fullscreenCurrentTime: document.getElementById('fullscreenCurrentTime'),
                fullscreenDuration: document.getElementById('fullscreenDuration'),
                fullscreenProgressBar: document.getElementById('fullscreenProgressBar'),
                fullscreenProgress: document.getElementById('fullscreenProgress'),
                fullscreenShuffleBtn: document.getElementById('fullscreenShuffleBtn'),
                fullscreenPrevBtn: document.getElementById('fullscreenPrevBtn'),
                fullscreenPlayBtn: document.getElementById('fullscreenPlayBtn'),
                fullscreenNextBtn: document.getElementById('fullscreenNextBtn'),
                fullscreenRepeatBtn: document.getElementById('fullscreenRepeatBtn'),
                fullscreenExitBtn: document.getElementById('fullscreenExitBtn'),
                
                // 专辑封面
                playerAlbumArt: document.getElementById('playerAlbumArt'),
                playerAlbumArtImg: document.querySelector('#playerAlbumArt img'),
                lyricsAlbumArtImg: document.querySelector('#lyricsAlbumArt img'),
                fullscreenAlbumArtImg: document.querySelector('#fullscreenAlbumArt img'),
                
                // 导航链接
                homeLink: document.getElementById('homeLink'),
                searchLink: document.getElementById('searchLink'),
                myMusicLibraryLink: document.getElementById('myMusicLibraryLink'),
                favoriteMusicLink: document.getElementById('favoriteMusicLink'),
                downloadsLink: document.getElementById('downloadsLink'),
                downloadManagementLink: document.getElementById('downloadManagementLink'),
                playHistoryLink: document.getElementById('playHistoryLink'),
                hotPlaylistLink1: document.getElementById('hotPlaylistLink1'),
                hotPlaylistLink2: document.getElementById('hotPlaylistLink2'),
                hotPlaylistLink3: document.getElementById('hotPlaylistLink3'),
                hotPlaylistLink4: document.getElementById('hotPlaylistLink4'),
                douyinHotLink: document.getElementById('douyinHotLink'),
                
                // 其他
                welcomeTitle: document.getElementById('welcomeTitle'),
                welcomeSubtitle: document.getElementById('welcomeSubtitle'),
                hotPlaylist: document.getElementById('hotPlaylist'),
                sourceBtns: document.querySelectorAll('.source-btn'),
                
                // 新增榜单相关元素
                chartsGrid: document.getElementById('chartsGrid'),
                refreshChartsBtn: document.getElementById('refreshChartsBtn'),
                
                // 抖音热榜相关元素
                refreshDouyinHotBtn: document.getElementById('refreshDouyinHotBtn'),
                douyinHotList: document.getElementById('douyinHotList'),
                douyinHotLoading: document.getElementById('douyinHotLoading')
            };

            // 应用状态管理
            const state = {
                isPlaying: false,
                currentSongIndex: -1,
                songs: [],
                currentTime: 0,
                duration: 0,
                volume: 80,
                isMuted: false,
                isShuffled: false,
                repeatMode: 'off',
                isLyricsVisible: false,
                isUpNextVisible: false,
                currentSource: 'netease',
                searchHistory: JSON.parse(localStorage.getItem('yueyinge_search_history')) || [],
                audioPlayer: new Audio(),
                playHistory: JSON.parse(localStorage.getItem('yueyinge_play_history')) || [],
                myMusicLibrary: JSON.parse(localStorage.getItem('yueyinge_my_music_library')) || [],
                favoriteMusic: JSON.parse(localStorage.getItem('yueyinge_favorite_music')) || [],
                downloads: JSON.parse(localStorage.getItem('yueyinge_downloads')) || [],
                upNextSongs: JSON.parse(localStorage.getItem('yueyinge_upnext_songs')) || [],
                currentView: 'default',
                isFullscreen: false,
                lyrics: [],
                currentLyricIndex: -1,
                theme: localStorage.getItem('yueyinge_theme') || 'light',
                currentDownloadSong: null,
                playerState: JSON.parse(localStorage.getItem('yueyinge_player_state')) || {
                    volume: 80,
                    isMuted: false,
                    isShuffled: false,
                    repeatMode: 'off',
                    currentSongIndex: -1,
                    currentTime: 0
                },
                currentAlbumArtBlobUrl: null,
                isAudioLoading: false,
                // 新增状态
                isAdminPanelVisible: false,
                feedbacks: JSON.parse(localStorage.getItem('yueyinge_feedbacks')) || [],
                userData: JSON.parse(localStorage.getItem('yueyinge_user_data')) || [],
                adminSettings: JSON.parse(localStorage.getItem('yueyinge_admin_settings')) || {
                    autoUploadInterval: 5,
                    maxFeedbackItems: 100
                },
                logoClickCount: 0,
                lastLogoClickTime: 0,
                autoUploadTimer: null,
                // 新增榜单状态
                chartsData: JSON.parse(localStorage.getItem('yueyinge_charts_data')) || {},
                chartsLastUpdated: localStorage.getItem('yueyinge_charts_last_updated') || 0,
                // 整点报时状态
                chimeSettings: JSON.parse(localStorage.getItem('yueyinge_chime_settings')) || {
                    enabled: true,
                    volume: 50,
                    startTime: "08:00",
                    endTime: "22:00"
                },
                chimeAudio: new Audio(),
                chimeTimer: null,
                lastChimeHour: -1,
                // API状态
                currentApi: localStorage.getItem('yueyinge_current_api') || 'main',
                apiSettings: JSON.parse(localStorage.getItem('yueyinge_api_settings')) || {
                    autoSwitch: true,
                    retryCount: 3
                },
                apiStatus: {
                    main: 'online',
                    backup: 'online',
                    douyin: 'online',
                    qishui: 'online'
                },
                // 抖音热榜状态
                douyinHotSongs: JSON.parse(localStorage.getItem('yueyinge_douyin_hot_songs')) || [],
                douyinHotLastUpdated: localStorage.getItem('yueyinge_douyin_hot_last_updated') || 0
            };

            // API配置 - 多API系统
            const API_CONFIG = {
                main: {
                    name: '主用API (网易云官方)',
                    search: 'https://node.api.xfabe.com/api/wangyi/search',
                    music: 'https://node.api.xfabe.com/api/wangyi/music',
                    lyrics: 'https://node.api.xfabe.com/api/wangyi/lyrics',
                    charts: 'https://node.api.xfabe.com/api/wangyi/musicChart'
                },
                backup: {
                    name: '备用API (GD Studio)',
                    search: 'https://music-api.gdstudio.xyz/api.php?types=search&source=netease&name=',
                    music: 'https://music-api.gdstudio.xyz/api.php?types=url&source=netease&id=',
                    lyrics: 'https://music-api.gdstudio.xyz/api.php?types=lyric&source=netease&id=',
                    pic: 'https://music-api.gdstudio.xyz/api.php?types=pic&source=netease&id='
                },
                douyin: {
                    name: '抖音点歌API',
                    search: 'https://api.cenguigui.cn/api/douyin/music/?msg=',
                    music: 'https://api.cenguigui.cn/api/douyin/music/?msg=',
                    type: 'json',
                    limit: 10
                },
                qishui: {
                    name: '汽水音乐API',
                    search: 'https://api.cenguigui.cn/api/qishui/?msg=',
                    music: 'https://api.cenguigui.cn/api/qishui/?msg=',
                    type: 'json'
                },
                douyinHot: {
                    name: '抖音热榜API',
                    url: 'https://api.cenguigui.cn/api/hotlist/dy/'
                }
            };

            const CHIME_API_URL = 'https://api.cenguigui.cn/api/chime/';

            // 初始化应用
            function initApp() {
                try {
                    loadUserData();
                    setupEventListeners();
                    loadHotSongs();
                    loadHotPlaylist();
                    updateWelcomeBanner();
                    setupThemeSystem();
                    restorePlayerState();
                    renderUpNextList();
                    startAutoUploadTimer();
                    loadCharts();
                    setupChimeSystem();
                    setupApiSystem();
                    loadDouyinHotSongs();
                    
                    console.log('🎵 悦音阁已初始化完成 - 多API全面优化版 v23.0.0');
                } catch (error) {
                    console.error('初始化应用时出错:', error);
                    showError('应用初始化失败，请刷新页面重试');
                }
            }

            // 设置API系统
            function setupApiSystem() {
                try {
                    // 更新API选择器状态
                    updateApiSelector();
                    
                    // 更新API状态显示
                    updateApiStatusDisplay();
                    
                    // 测试API连接状态
                    testApiConnection();
                    
                    console.log('API系统已初始化');
                } catch (error) {
                    console.error('设置API系统时出错:', error);
                }
            }

            // 更新API选择器
            function updateApiSelector() {
                try {
                    // 移除所有active类
                    elements.apiBtns.forEach(btn => {
                        btn.classList.remove('active');
                    });
                    
                    // 激活当前API按钮
                    const currentApiBtn = document.querySelector(`.api-btn[data-api="${state.currentApi}"]`);
                    if (currentApiBtn) {
                        currentApiBtn.classList.add('active');
                    }
                    
                    // 更新状态文本
                    elements.apiStatusText.textContent = `当前使用: ${API_CONFIG[state.currentApi].name}`;
                } catch (error) {
                    console.error('更新API选择器时出错:', error);
                }
            }

            // 更新API状态显示
            function updateApiStatusDisplay() {
                try {
                    // 更新主状态指示器
                    const currentStatus = state.apiStatus[state.currentApi];
                    elements.mainApiStatusIndicator.className = `api-status-indicator ${currentStatus === 'online' ? '' : 'offline'}`;
                    
                    // 更新后台状态指示器
                    elements.apiStatusIndicator.className = `api-status-indicator ${currentStatus === 'online' ? '' : 'offline'}`;
                    
                    // 更新状态文本
                    const statusText = `${API_CONFIG[state.currentApi].name} - ${currentStatus === 'online' ? '在线' : '离线'}`;
                    elements.apiStatusText.textContent = statusText;
                } catch (error) {
                    console.error('更新API状态显示时出错:', error);
                }
            }

            // 测试API连接状态
            function testApiConnection() {
                try {
                    // 测试所有API
                    Object.keys(API_CONFIG).forEach(api => {
                        if (api !== 'douyinHot') { // 抖音热榜API不需要测试连接
                            testSingleApi(api, '周杰伦').then(online => {
                                state.apiStatus[api] = online ? 'online' : 'offline';
                                updateApiStatusDisplay();
                            });
                        }
                    });
                } catch (error) {
                    console.error('测试API连接状态时出错:', error);
                }
            }

            // 测试单个API
            function testSingleApi(api, testQuery) {
                return new Promise((resolve) => {
                    try {
                        let testUrl;
                        
                        if (api === 'main') {
                            testUrl = `${API_CONFIG.main.search}?search=${encodeURIComponent(testQuery)}&limit=1`;
                        } else if (api === 'backup') {
                            testUrl = `${API_CONFIG.backup.search}${encodeURIComponent(testQuery)}&count=1&pages=1`;
                        } else if (api === 'douyin') {
                            testUrl = `${API_CONFIG.douyin.search}${encodeURIComponent(testQuery)}&page=1&limit=1&type=json`;
                        } else if (api === 'qishui') {
                            testUrl = `${API_CONFIG.qishui.search}${encodeURIComponent(testQuery)}&type=json&n=1`;
                        }
                        
                        if (!testUrl) {
                            resolve(false);
                            return;
                        }
                        
                        fetch(testUrl, { method: 'GET' })
                            .then(response => {
                                if (!response.ok) {
                                    resolve(false);
                                    return;
                                }
                                return response.json();
                            })
                            .then(data => {
                                if (data) {
                                    // 检查数据是否有效
                                    let isValid = false;
                                    
                                    if (api === 'main') {
                                        isValid = data && data.code === 200 && data.data && data.data.songs;
                                    } else if (api === 'backup') {
                                        isValid = data && Array.isArray(data) && data.length > 0;
                                    } else if (api === 'douyin') {
                                        isValid = data && data.code === 200 && data.data;
                                    } else if (api === 'qishui') {
                                        isValid = data && data.code === 200 && data.data;
                                    }
                                    
                                    resolve(isValid);
                                } else {
                                    resolve(false);
                                }
                            })
                            .catch(error => {
                                console.error(`测试${api} API失败:`, error);
                                resolve(false);
                            });
                    } catch (error) {
                        console.error(`测试${api} API时出错:`, error);
                        resolve(false);
                    }
                });
            }

            // 切换API
            function switchApi(newApi) {
                try {
                    if (state.currentApi === newApi) return;
                    
                    state.currentApi = newApi;
                    localStorage.setItem('yueyinge_current_api', newApi);
                    
                    // 更新UI
                    updateApiSelector();
                    updateApiStatusDisplay();
                    
                    // 显示切换消息
                    showSuccess(`已切换到${API_CONFIG[newApi].name}`);
                    
                    // 如果当前有搜索内容，重新搜索
                    if (elements.searchInput.value.trim()) {
                        performSearch();
                    }
                } catch (error) {
                    console.error('切换API时出错:', error);
                    showError('切换API失败');
                }
            }

            // 获取搜索URL
            function getSearchUrl(query, limit = 30) {
                try {
                    if (state.currentApi === 'main') {
                        return `${API_CONFIG.main.search}?search=${encodeURIComponent(query)}&limit=${limit}`;
                    } else if (state.currentApi === 'backup') {
                        return `${API_CONFIG.backup.search}${encodeURIComponent(query)}&count=${limit}&pages=1`;
                    } else if (state.currentApi === 'douyin') {
                        return `${API_CONFIG.douyin.search}${encodeURIComponent(query)}&page=1&limit=${limit}&type=json`;
                    } else if (state.currentApi === 'qishui') {
                        return `${API_CONFIG.qishui.search}${encodeURIComponent(query)}&type=json`;
                    }
                    return '';
                } catch (error) {
                    console.error('获取搜索URL时出错:', error);
                    return '';
                }
            }

            // 获取音乐URL - 修复主用API和备用API的问题
            function getMusicUrl(songId, songData = null) {
                try {
                    if (state.currentApi === 'main') {
                        return `${API_CONFIG.main.music}?type=json&id=${songId}`;
                    } else if (state.currentApi === 'backup') {
                        return `${API_CONFIG.backup.music}${songId}&br=320`;
                    } else if (state.currentApi === 'douyin') {
                        // 抖音API在搜索时已经返回了播放链接
                        return songData && songData.url ? songData.url : null;
                    } else if (state.currentApi === 'qishui') {
                        // 汽水API在搜索时已经返回了播放链接
                        return songData && songData.music ? songData.music : null;
                    }
                    return null;
                } catch (error) {
                    console.error('获取音乐URL时出错:', error);
                    return null;
                }
            }

            // 获取歌词URL
            function getLyricsUrl(songId, songData = null) {
                try {
                    if (state.currentApi === 'main') {
                        return `${API_CONFIG.main.lyrics}?id=${songId}`;
                    } else if (state.currentApi === 'backup') {
                        return `${API_CONFIG.backup.lyrics}${songId}`;
                    } else if (state.currentApi === 'douyin') {
                        // 抖音API在搜索时已经返回了歌词
                        return songData && songData.lrc ? songData.lrc : null;
                    } else if (state.currentApi === 'qishui') {
                        // 汽水API在搜索时已经返回了歌词
                        return songData && songData.lrc ? songData.lrc : null;
                    }
                    return null;
                } catch (error) {
                    console.error('获取歌词URL时出错:', error);
                    return null;
                }
            }

            // 处理搜索响应数据 - 修复API数据处理问题
            function processSearchResponse(data) {
                try {
                    if (state.currentApi === 'main') {
                        // 主用API响应格式
                        if (data && data.code === 200 && data.data && data.data.songs && data.data.songs.length > 0) {
                            return data.data.songs.map(song => ({
                                id: song.id,
                                name: song.name,
                                artistsname: song.artistsname,
                                artist: song.artistsname,
                                album: song.album,
                                duration: song.duration,
                                picurl: song.picurl,
                                source: 'netease'
                            }));
                        }
                    } else if (state.currentApi === 'backup') {
                        // 备用API响应格式
                        if (data && Array.isArray(data) && data.length > 0) {
                            return data.map(song => ({
                                id: song.id,
                                name: song.name,
                                artistsname: song.artist,
                                artist: song.artist,
                                album: song.album,
                                duration: 0,
                                pic_id: song.pic_id,
                                picurl: song.pic_id ? `${API_CONFIG.backup.pic}${song.pic_id}` : '',
                                source: 'netease'
                            }));
                        }
                    } else if (state.currentApi === 'douyin') {
                        // 抖音API响应格式
                        if (data && data.code === 200 && data.data) {
                            return [{
                                id: data.data.title,
                                name: data.data.title,
                                artistsname: data.data.singer,
                                artist: data.data.singer,
                                album: '',
                                duration: 0,
                                picurl: data.data.cover,
                                url: data.data.url,
                                lrc: data.data.lrc,
                                source: 'douyin'
                            }];
                        }
                    } else if (state.currentApi === 'qishui') {
                        // 汽水API响应格式
                        if (data && data.code === 200 && data.data) {
                            return [{
                                id: data.data.title,
                                name: data.data.title,
                                artistsname: data.data.singer,
                                artist: data.data.singer,
                                album: '',
                                duration: 0,
                                picurl: data.data.cover,
                                url: data.data.music,
                                lrc: data.data.lrc,
                                source: 'qishui',
                                isPaid: data.data.pay === 'pay'
                            }];
                        }
                    }
                    return [];
                } catch (error) {
                    console.error('处理搜索响应数据时出错:', error);
                    return [];
                }
            }

            // 处理音乐URL响应数据 - 修复主用API和备用API的问题
            function processMusicUrlResponse(data) {
                try {
                    if (state.currentApi === 'main') {
                        // 主用API响应格式
                        if (data && data.code === 200 && data.data) {
                            return {
                                url: data.data.url,
                                br: data.data.br,
                                size: data.data.size,
                                picurl: data.data.picurl
                            };
                        }
                    } else if (state.currentApi === 'backup') {
                        // 备用API响应格式
                        if (data && data.url) {
                            return {
                                url: data.url,
                                br: data.br,
                                size: data.size
                            };
                        }
                    }
                    // 抖音和汽水API不需要处理，因为播放链接已经在搜索时获取
                    return null;
                } catch (error) {
                    console.error('处理音乐URL响应数据时出错:', error);
                    return null;
                }
            }

            // 处理歌词响应数据
            function processLyricsResponse(data) {
                try {
                    if (state.currentApi === 'main') {
                        // 主用API响应格式
                        if (data && data.code === 200 && data.data && data.data.lyric) {
                            return data.data.lyric;
                        }
                    } else if (state.currentApi === 'backup') {
                        // 备用API响应格式
                        if (data && data.lyric) {
                            return data.lyric;
                        }
                    }
                    // 抖音和汽水API不需要处理，因为歌词已经在搜索时获取
                    return null;
                } catch (error) {
                    console.error('处理歌词响应数据时出错:', error);
                    return null;
                }
            }

            // 测试当前API
            function testCurrentApi() {
                try {
                    const query = elements.apiTestQuery.value.trim() || '周杰伦';
                    
                    showLoading();
                    
                    const searchUrl = getSearchUrl(query, 1);
                    
                    fetch(searchUrl)
                        .then(response => {
                            if (!response.ok) {
                                throw new Error(`HTTP error! status: ${response.status}`);
                            }
                            return response.json();
                        })
                        .then(data => {
                            hideLoading();
                            
                            const songs = processSearchResponse(data);
                            
                            if (songs.length > 0) {
                                showSuccess(`${API_CONFIG[state.currentApi].name} 测试成功！找到 ${songs.length} 首相关歌曲`);
                                state.apiStatus[state.currentApi] = 'online';
                            } else {
                                showError(`${API_CONFIG[state.currentApi].name} 测试失败：未找到相关歌曲`);
                                state.apiStatus[state.currentApi] = 'offline';
                            }
                            
                            updateApiStatusDisplay();
                        })
                        .catch(error => {
                            hideLoading();
                            console.error('API测试失败:', error);
                            showError(`${API_CONFIG[state.currentApi].name} 测试失败：${error.message}`);
                            state.apiStatus[state.currentApi] = 'offline';
                            updateApiStatusDisplay();
                        });
                } catch (error) {
                    hideLoading();
                    console.error('测试当前API时出错:', error);
                    showError('API测试失败');
                }
            }

            // 保存API设置
            function saveApiSettings() {
                try {
                    localStorage.setItem('yueyinge_api_settings', JSON.stringify(state.apiSettings));
                    showSuccess('API设置已保存');
                } catch (error) {
                    console.error('保存API设置时出错:', error);
                    showError('保存设置失败');
                }
            }

            // 重置API设置
            function resetApiSettings() {
                try {
                    state.currentApi = 'main';
                    state.apiSettings = {
                        autoSwitch: true,
                        retryCount: 3
                    };
                    
                    localStorage.setItem('yueyinge_current_api', state.currentApi);
                    localStorage.setItem('yueyinge_api_settings', JSON.stringify(state.apiSettings));
                    
                    updateApiSelector();
                    updateApiStatusDisplay();
                    
                    showSuccess('API设置已恢复默认');
                } catch (error) {
                    console.error('重置API设置时出错:', error);
                    showError('重置设置失败');
                }
            }

            // 设置整点报时系统
            function setupChimeSystem() {
                try {
                    // 更新UI设置
                    updateChimeSettingsUI();
                    
                    // 启动整点报时检查
                    startChimeTimer();
                    
                    console.log('整点报时系统已初始化');
                } catch (error) {
                    console.error('设置整点报时系统时出错:', error);
                }
            }

            // 更新整点报时设置UI
            function updateChimeSettingsUI() {
                try {
                    elements.chimeEnabled.checked = state.chimeSettings.enabled;
                    elements.chimeVolume.value = state.chimeSettings.volume;
                    elements.chimeVolumeValue.textContent = `${state.chimeSettings.volume}%`;
                    elements.chimeStartTime.value = state.chimeSettings.startTime;
                    elements.chimeEndTime.value = state.chimeSettings.endTime;
                } catch (error) {
                    console.error('更新整点报时设置UI时出错:', error);
                }
            }

            // 启动整点报时定时器
            function startChimeTimer() {
                try {
                    // 清除现有定时器
                    if (state.chimeTimer) {
                        clearInterval(state.chimeTimer);
                    }
                    
                    // 每分钟检查一次是否到达整点
                    state.chimeTimer = setInterval(() => {
                        checkChime();
                    }, 60000);
                    
                    // 立即检查一次
                    checkChime();
                } catch (error) {
                    console.error('启动整点报时定时器时出错:', error);
                }
            }

            // 检查整点报时
            function checkChime() {
                try {
                    if (!state.chimeSettings.enabled) {
                        return;
                    }
                    
                    const now = new Date();
                    const currentHour = now.getHours();
                    const currentMinute = now.getMinutes();
                    
                    // 只在整点（分钟为0）时触发，并且避免重复触发
                    if (currentMinute === 0 && currentHour !== state.lastChimeHour) {
                        // 检查是否在允许的时间范围内
                        const startTime = parseTimeString(state.chimeSettings.startTime);
                        const endTime = parseTimeString(state.chimeSettings.endTime);
                        
                        if (isTimeInRange(currentHour, startTime, endTime)) {
                            // 播放整点报时
                            playChime(currentHour);
                            state.lastChimeHour = currentHour;
                        }
                    } else if (currentMinute !== 0) {
                        // 重置上次报时小时，以便下一个整点可以再次触发
                        state.lastChimeHour = -1;
                    }
                } catch (error) {
                    console.error('检查整点报时时出错:', error);
                }
            }

            // 解析时间字符串
            function parseTimeString(timeString) {
                try {
                    const [hours, minutes] = timeString.split(':').map(Number);
                    return { hours, minutes };
                } catch (error) {
                    console.error('解析时间字符串时出错:', error);
                    return { hours: 0, minutes: 0 };
                }
            }

            // 检查时间是否在范围内
            function isTimeInRange(currentHour, startTime, endTime) {
                try {
                    // 如果开始时间小于结束时间，表示时间范围在同一天
                    if (startTime.hours < endTime.hours) {
                        return currentHour >= startTime.hours && currentHour < endTime.hours;
                    } 
                    // 如果开始时间大于结束时间，表示时间范围跨越午夜
                    else if (startTime.hours > endTime.hours) {
                        return currentHour >= startTime.hours || currentHour < endTime.hours;
                    }
                    // 如果开始时间等于结束时间，表示全天
                    else {
                        return true;
                    }
                } catch (error) {
                    console.error('检查时间范围时出错:', error);
                    return true;
                }
            }

            // 播放整点报时
            function playChime(hour) {
                try {
                    // 显示报时指示器
                    showChimeIndicator(hour);
                    
                    // 构建API URL
                    const apiUrl = `${CHIME_API_URL}?time=${hour}`;
                    
                    // 设置音频源
                    state.chimeAudio.src = apiUrl;
                    state.chimeAudio.volume = state.chimeSettings.volume / 100;
                    
                    // 播放音频
                    state.chimeAudio.play().then(() => {
                        console.log(`整点报时播放成功: ${hour}点`);
                    }).catch(error => {
                        console.error('整点报时播放失败:', error);
                        hideChimeIndicator();
                    });
                    
                    // 音频播放结束后隐藏指示器
                    state.chimeAudio.addEventListener('ended', () => {
                        hideChimeIndicator();
                    });
                    
                    // 音频加载失败时隐藏指示器
                    state.chimeAudio.addEventListener('error', () => {
                        console.error('整点报时音频加载失败');
                        hideChimeIndicator();
                    });
                } catch (error) {
                    console.error('播放整点报时时出错:', error);
                    hideChimeIndicator();
                }
            }

            // 显示整点报时指示器
            function showChimeIndicator(hour) {
                try {
                    elements.chimeText.textContent = `整点报时: ${hour}点`;
                    elements.chimeIndicator.classList.add('show');
                } catch (error) {
                    console.error('显示整点报时指示器时出错:', error);
                }
            }

            // 隐藏整点报时指示器
            function hideChimeIndicator() {
                try {
                    elements.chimeIndicator.classList.remove('show');
                } catch (error) {
                    console.error('隐藏整点报时指示器时出错:', error);
                }
            }

            // 测试整点报时
            function testChime(hour = null) {
                try {
                    const testHour = hour !== null ? hour : new Date().getHours();
                    playChime(testHour);
                } catch (error) {
                    console.error('测试整点报时时出错:', error);
                    showError('测试整点报时失败');
                }
            }

            // 测试报时音量
            function testChimeVolume() {
                try {
                    // 播放一个简短的测试音
                    const testAudio = new Audio();
                    testAudio.src = 'data:audio/wav;base64,UklGRigAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQQAAAAAAA==';
                    testAudio.volume = state.chimeSettings.volume / 100;
                    
                    testAudio.play().then(() => {
                        showSuccess(`报时音量测试: ${state.chimeSettings.volume}%`);
                    }).catch(error => {
                        console.error('测试音量播放失败:', error);
                        showError('音量测试失败');
                    });
                } catch (error) {
                    console.error('测试报时音量时出错:', error);
                    showError('音量测试失败');
                }
            }

            // 保存整点报时设置
            function saveChimeSettings() {
                try {
                    state.chimeSettings.enabled = elements.chimeEnabled.checked;
                    state.chimeSettings.volume = parseInt(elements.chimeVolume.value);
                    state.chimeSettings.startTime = elements.chimeStartTime.value;
                    state.chimeSettings.endTime = elements.chimeEndTime.value;
                    
                    // 保存到本地存储
                    localStorage.setItem('yueyinge_chime_settings', JSON.stringify(state.chimeSettings));
                    
                    // 更新音量显示
                    elements.chimeVolumeValue.textContent = `${state.chimeSettings.volume}%`;
                    
                    // 重新启动整点报时定时器
                    startChimeTimer();
                    
                    showSuccess('整点报时设置已保存');
                } catch (error) {
                    console.error('保存整点报时设置时出错:', error);
                    showError('保存设置失败');
                }
            }

            // 重置整点报时设置
            function resetChimeSettings() {
                try {
                    state.chimeSettings = {
                        enabled: true,
                        volume: 50,
                        startTime: "08:00",
                        endTime: "22:00"
                    };
                    
                    // 更新UI
                    updateChimeSettingsUI();
                    
                    // 保存到本地存储
                    localStorage.setItem('yueyinge_chime_settings', JSON.stringify(state.chimeSettings));
                    
                    // 重新启动整点报时定时器
                    startChimeTimer();
                    
                    showSuccess('整点报时设置已恢复默认');
                } catch (error) {
                    console.error('重置整点报时设置时出错:', error);
                    showError('重置设置失败');
                }
            }

            // 加载抖音热榜歌曲
            function loadDouyinHotSongs(forceRefresh = false) {
                try {
                    const now = Date.now();
                    const oneHour = 60 * 60 * 1000;
                    
                    // 检查是否需要刷新数据
                    if (!forceRefresh && 
                        state.douyinHotSongs.length > 0 && 
                        now - state.douyinHotLastUpdated < oneHour) {
                        // 使用缓存数据
                        renderDouyinHotSongs();
                        return;
                    }
                    
                    showDouyinHotLoading();
                    
                    fetch(API_CONFIG.douyinHot.url)
                        .then(response => {
                            if (!response.ok) {
                                throw new Error(`HTTP error! status: ${response.status}`);
                            }
                            return response.json();
                        })
                        .then(data => {
                            hideDouyinHotLoading();
                            
                            if (data && data.code === 200 && data.data) {
                                // 转换歌曲格式
                                state.douyinHotSongs = data.data.map(item => ({
                                    id: item.id,
                                    name: item.title,
                                    artistsname: item.artist,
                                    artist: item.artist,
                                    album: item.album,
                                    duration: 0,
                                    picurl: item.pic,
                                    url: item.url,
                                    lrc: item.lyric,
                                    source: 'douyin'
                                }));
                                
                                state.douyinHotLastUpdated = now;
                                
                                // 保存到本地存储
                                localStorage.setItem('yueyinge_douyin_hot_songs', JSON.stringify(state.douyinHotSongs));
                                localStorage.setItem('yueyinge_douyin_hot_last_updated', state.douyinHotLastUpdated.toString());
                                
                                renderDouyinHotSongs();
                            } else {
                                showDouyinHotError('获取抖音热榜失败');
                            }
                        })
                        .catch(error => {
                            hideDouyinHotLoading();
                            console.error('加载抖音热榜失败:', error);
                            showDouyinHotError('加载抖音热榜失败，请检查网络连接');
                        });
                } catch (error) {
                    hideDouyinHotLoading();
                    console.error('加载抖音热榜时出错:', error);
                    showDouyinHotError('加载抖音热榜失败');
                }
            }

            // 显示抖音热榜加载状态
            function showDouyinHotLoading() {
                try {
                    elements.douyinHotLoading.style.display = 'flex';
                } catch (error) {
                    console.error('显示抖音热榜加载状态时出错:', error);
                }
            }

            // 隐藏抖音热榜加载状态
            function hideDouyinHotLoading() {
                try {
                    elements.douyinHotLoading.style.display = 'none';
                } catch (error) {
                    console.error('隐藏抖音热榜加载状态时出错:', error);
                }
            }

            // 显示抖音热榜错误
            function showDouyinHotError(message) {
                try {
                    elements.douyinHotList.innerHTML = `
                        <div class="error-message show">
                            <i class="fas fa-exclamation-circle"></i>
                            <span>${message}</span>
                        </div>
                    `;
                } catch (error) {
                    console.error('显示抖音热榜错误时出错:', error);
                }
            }

            // 渲染抖音热榜歌曲
            function renderDouyinHotSongs() {
                try {
                    if (state.douyinHotSongs.length === 0) {
                        elements.douyinHotList.innerHTML = `
                            <div class="no-lyrics">
                                <i class="fab fa-tiktok"></i>
                                <div>暂无抖音热榜数据</div>
                            </div>
                        `;
                        return;
                    }
                    
                    let html = '';
                    
                    state.douyinHotSongs.forEach((song, index) => {
                        html += `
                            <div class="song-item" data-index="${index}" data-source="douyinHot">
                                <div class="song-number">${index + 1}</div>
                                <div class="song-info">
                                    <div class="song-name">${song.name}</div>
                                    <div class="song-artist">${song.artistsname || song.artist}</div>
                                </div>
                                <div class="song-duration">--:--</div>
                                <div class="song-actions">
                                    <button class="song-action-btn" data-action="favorite" data-index="${index}" data-source="douyinHot">
                                        <i class="fas fa-heart"></i>
                                    </button>
                                    <button class="song-action-btn" data-action="add-to-upnext" data-index="${index}" data-source="douyinHot">
                                        <i class="fas fa-plus"></i>
                                    </button>
                                    <button class="song-action-btn" data-action="download" data-index="${index}" data-source="douyinHot">
                                        <i class="fas fa-download"></i>
                                    </button>
                                </div>
                            </div>
                        `;
                    });
                    
                    elements.douyinHotList.innerHTML = html;
                    
                    // 添加歌曲点击事件
                    document.querySelectorAll('#douyinHotList .song-item').forEach(item => {
                        item.addEventListener('click', (e) => {
                            if (!e.target.closest('.song-actions')) {
                                const index = parseInt(item.dataset.index);
                                const song = state.douyinHotSongs[index];
                                playSong(song, index, state.douyinHotSongs);
                            }
                        });
                    });
                    
                    // 添加按钮点击事件
                    document.querySelectorAll('#douyinHotList .song-action-btn').forEach(btn => {
                        btn.addEventListener('click', (e) => {
                            e.stopPropagation();
                            const action = btn.dataset.action;
                            const index = parseInt(btn.dataset.index);
                            const song = state.douyinHotSongs[index];
                            
                            switch (action) {
                                case 'favorite':
                                    toggleFavorite(song, index);
                                    break;
                                case 'add-to-upnext':
                                    addToUpNext(song);
                                    break;
                                case 'download':
                                    showDownloadOptions(song);
                                    break;
                            }
                        });
                    });
                } catch (error) {
                    console.error('渲染抖音热榜歌曲时出错:', error);
                    showDouyinHotError('渲染抖音热榜失败');
                }
            }

            // 设置主题系统
            function setupThemeSystem() {
                try {
                    document.documentElement.setAttribute('data-theme', state.theme);
                    elements.themeToggleBtn.innerHTML = state.theme === 'light' ? 
                        '<i class="fas fa-moon"></i>' : '<i class="fas fa-sun"></i>';
                } catch (error) {
                    console.error('设置主题系统时出错:', error);
                }
            }

            // 切换主题
            function toggleTheme() {
                try {
                    state.theme = state.theme === 'light' ? 'dark' : 'light';
                    document.documentElement.setAttribute('data-theme', state.theme);
                    elements.themeToggleBtn.innerHTML = state.theme === 'light' ? 
                        '<i class="fas fa-moon"></i>' : '<i class="fas fa-sun"></i>';
                    
                    localStorage.setItem('yueyinge_theme', state.theme);
                } catch (error) {
                    console.error('切换主题时出错:', error);
                }
            }

            // 恢复播放器状态
            function restorePlayerState() {
                try {
                    // 恢复音量设置
                    elements.volumeSlider.value = state.playerState.volume;
                    state.audioPlayer.volume = state.playerState.volume / 100;
                    state.volume = state.playerState.volume;
                    
                    // 恢复静音状态
                    state.isMuted = state.playerState.isMuted;
                    state.audioPlayer.muted = state.playerState.isMuted;
                    elements.volumeBtn.innerHTML = state.isMuted ? 
                        '<i class="fas fa-volume-mute"></i>' : '<i class="fas fa-volume-up"></i>';
                    
                    // 恢复随机播放状态
                    state.isShuffled = state.playerState.isShuffled;
                    updateShuffleButton();
                    
                    // 恢复循环模式
                    state.repeatMode = state.playerState.repeatMode;
                    updateRepeatButton();
                    
                    // 恢复播放状态
                    if (state.playerState.currentSongIndex >= 0 && state.songs.length > 0) {
                        state.currentSongIndex = state.playerState.currentSongIndex;
                        const song = state.songs[state.currentSongIndex];
                        
                        updatePlayerUI(song);
                        
                        // 恢复播放进度
                        state.currentTime = state.playerState.currentTime;
                        state.audioPlayer.currentTime = state.currentTime;
                        
                        // 加载歌词
                        loadLyrics(song);
                        
                        // 恢复播放状态
                        if (state.playerState.currentTime > 0) {
                            state.isPlaying = true;
                            updateAllPlayButtons();
                        }
                    }
                } catch (error) {
                    console.error('恢复播放器状态时出错:', error);
                }
            }

            // 更新播放器UI
            function updatePlayerUI(song) {
                try {
                    // 更新播放器信息
                    document.querySelector('.player-song-title').textContent = song.name;
                    document.querySelector('.player-song-artist').textContent = song.artistsname || song.artist;
                    
                    // 更新歌词页面信息
                    elements.lyricsSongTitle.textContent = song.name;
                    elements.lyricsSongArtist.textContent = song.artistsname || song.artist;
                    
                    // 更新全屏界面信息
                    elements.fullscreenTitle.textContent = song.name;
                    elements.fullscreenArtist.textContent = song.artistsname || song.artist;
                    elements.fullscreenAlbum.textContent = song.album || '未知专辑';
                    
                    // 更新专辑封面
                    if (song.picurl) {
                        updateAlbumArt(song.picurl, song.album);
                    } else {
                        resetAlbumArt();
                    }
                    
                    // 更新收藏按钮状态
                    updateFavoriteButtonState(song);
                    
                    // 更新时长显示
                    if (song.duration && song.duration > 0) {
                        elements.duration.textContent = formatTime(song.duration / 1000);
                        elements.fullscreenDuration.textContent = formatTime(song.duration / 1000);
                    } else {
                        elements.duration.textContent = '--:--';
                        elements.fullscreenDuration.textContent = '--:--';
                    }
                } catch (error) {
                    console.error('更新播放器UI时出错:', error);
                }
            }

            // 更新专辑封面 - 修复封面显示问题
            function updateAlbumArt(picUrl, album) {
                try {
                    // 释放之前的Blob URL
                    if (state.currentAlbumArtBlobUrl) {
                        URL.revokeObjectURL(state.currentAlbumArtBlobUrl);
                        state.currentAlbumArtBlobUrl = null;
                    }
                    
                    // 直接使用API返回的URL
                    state.currentAlbumArtBlobUrl = picUrl;
                    
                    // 更新所有专辑封面
                    elements.playerAlbumArtImg.src = picUrl;
                    elements.playerAlbumArtImg.alt = album || '专辑封面';
                    
                    elements.lyricsAlbumArtImg.src = picUrl;
                    elements.lyricsAlbumArtImg.alt = album || '专辑封面';
                    
                    elements.fullscreenAlbumArtImg.src = picUrl;
                    elements.fullscreenAlbumArtImg.alt = album || '专辑封面';
                    
                    console.log('专辑封面已更新:', picUrl);
                } catch (error) {
                    console.error('更新专辑封面时出错:', error);
                    resetAlbumArt();
                }
            }

            // 重置专辑封面
            function resetAlbumArt() {
                try {
                    if (state.currentAlbumArtBlobUrl) {
                        URL.revokeObjectURL(state.currentAlbumArtBlobUrl);
                        state.currentAlbumArtBlobUrl = null;
                    }

                    // 重置所有专辑封面
                    const albumArts = [elements.playerAlbumArtImg, elements.lyricsAlbumArtImg, elements.fullscreenAlbumArtImg];
                    albumArts.forEach(img => {
                        img.src = '';
                        img.alt = '专辑封面';
                    });
                } catch (error) {
                    console.error('重置专辑封面时出错:', error);
                }
            }

            // 保存播放器状态
            function savePlayerState() {
                try {
                    state.playerState = {
                        volume: state.volume,
                        isMuted: state.isMuted,
                        isShuffled: state.isShuffled,
                        repeatMode: state.repeatMode,
                        currentSongIndex: state.currentSongIndex,
                        currentTime: state.audioPlayer.currentTime || 0
                    };
                    
                    localStorage.setItem('yueyinge_player_state', JSON.stringify(state.playerState));
                } catch (error) {
                    console.error('保存播放器状态时出错:', error);
                }
            }

            // 加载用户数据
            function loadUserData() {
                try {
                    state.playHistory = JSON.parse(localStorage.getItem('yueyinge_play_history')) || [];
                    state.searchHistory = JSON.parse(localStorage.getItem('yueyinge_search_history')) || [];
                    state.myMusicLibrary = JSON.parse(localStorage.getItem('yueyinge_my_music_library')) || [];
                    state.favoriteMusic = JSON.parse(localStorage.getItem('yueyinge_favorite_music')) || [];
                    state.downloads = JSON.parse(localStorage.getItem('yueyinge_downloads')) || [];
                    state.upNextSongs = JSON.parse(localStorage.getItem('yueyinge_upnext_songs')) || [];
                    state.feedbacks = JSON.parse(localStorage.getItem('yueyinge_feedbacks')) || [];
                    state.userData = JSON.parse(localStorage.getItem('yueyinge_user_data')) || [];
                    state.adminSettings = JSON.parse(localStorage.getItem('yueyinge_admin_settings')) || {
                        autoUploadInterval: 5,
                        maxFeedbackItems: 100
                    };
                    state.chartsData = JSON.parse(localStorage.getItem('yueyinge_charts_data')) || {};
                    state.chartsLastUpdated = localStorage.getItem('yueyinge_charts_last_updated') || 0;
                    state.chimeSettings = JSON.parse(localStorage.getItem('yueyinge_chime_settings')) || {
                        enabled: true,
                        volume: 50,
                        startTime: "08:00",
                        endTime: "22:00"
                    };
                    state.currentApi = localStorage.getItem('yueyinge_current_api') || 'main';
                    state.apiSettings = JSON.parse(localStorage.getItem('yueyinge_api_settings')) || {
                        autoSwitch: true,
                        retryCount: 3
                    };
                    state.douyinHotSongs = JSON.parse(localStorage.getItem('yueyinge_douyin_hot_songs')) || [];
                    state.douyinHotLastUpdated = localStorage.getItem('yueyinge_douyin_hot_last_updated') || 0;
                    
                    updateSearchHistoryUI();
                    updateAdminSettingsUI();
                } catch (error) {
                    console.error('加载用户数据时出错:', error);
                }
            }

            // 保存用户数据
            function saveUserData() {
                try {
                    localStorage.setItem('yueyinge_play_history', JSON.stringify(state.playHistory));
                    localStorage.setItem('yueyinge_search_history', JSON.stringify(state.searchHistory));
                    localStorage.setItem('yueyinge_my_music_library', JSON.stringify(state.myMusicLibrary));
                    localStorage.setItem('yueyinge_favorite_music', JSON.stringify(state.favoriteMusic));
                    localStorage.setItem('yueyinge_downloads', JSON.stringify(state.downloads));
                    localStorage.setItem('yueyinge_upnext_songs', JSON.stringify(state.upNextSongs));
                    localStorage.setItem('yueyinge_feedbacks', JSON.stringify(state.feedbacks));
                    localStorage.setItem('yueyinge_user_data', JSON.stringify(state.userData));
                    localStorage.setItem('yueyinge_admin_settings', JSON.stringify(state.adminSettings));
                    localStorage.setItem('yueyinge_charts_data', JSON.stringify(state.chartsData));
                    localStorage.setItem('yueyinge_charts_last_updated', state.chartsLastUpdated);
                    localStorage.setItem('yueyinge_chime_settings', JSON.stringify(state.chimeSettings));
                    localStorage.setItem('yueyinge_current_api', state.currentApi);
                    localStorage.setItem('yueyinge_api_settings', JSON.stringify(state.apiSettings));
                    localStorage.setItem('yueyinge_douyin_hot_songs', JSON.stringify(state.douyinHotSongs));
                    localStorage.setItem('yueyinge_douyin_hot_last_updated', state.douyinHotLastUpdated);
                } catch (error) {
                    console.error('保存用户数据时出错:', error);
                }
            }

            // 更新欢迎横幅
            function updateWelcomeBanner() {
                try {
                    const hour = new Date().getHours();
                    let greeting = '';
                    let subtitle = '';
                    
                    if (hour >= 5 && hour < 9) {
                        greeting = '早上好';
                        subtitle = '新的一天，让音乐唤醒你的活力';
                    } else if (hour >= 9 && hour < 12) {
                        greeting = '上午好';
                        subtitle = '工作学习之余，让音乐放松心情';
                    } else if (hour >= 12 && hour < 14) {
                        greeting = '中午好';
                        subtitle = '午餐时间，享受美食与音乐';
                    } else if (hour >= 14 && hour < 18) {
                        greeting = '下午好';
                        subtitle = '午后时光，让音乐陪伴你度过';
                    } else if (hour >= 18 && hour < 22) {
                        greeting = '晚上好';
                        subtitle = '让音乐点亮你的生活，发现更多精彩内容';
                    } else {
                        greeting = '深夜好';
                        subtitle = '夜深人静，让音乐抚慰你的心灵';
                    }
                    
                    elements.welcomeTitle.textContent = `${greeting}，音乐爱好者`;
                    elements.welcomeSubtitle.textContent = subtitle;
                } catch (error) {
                    console.error('更新欢迎横幅时出错:', error);
                }
            }

            // 设置事件监听器
            function setupEventListeners() {
                try {
                    // API相关事件
                    elements.apiBtns.forEach(btn => {
                        btn.addEventListener('click', () => {
                            const api = btn.dataset.api;
                            switchApi(api);
                        });
                    });
                    
                    elements.testApiBtn.addEventListener('click', testCurrentApi);
                    elements.saveApiSettingsBtn.addEventListener('click', saveApiSettings);
                    elements.resetApiSettingsBtn.addEventListener('click', resetApiSettings);
                    
                    // 整点报时相关事件
                    elements.chimeVolume.addEventListener('input', () => {
                        elements.chimeVolumeValue.textContent = `${elements.chimeVolume.value}%`;
                    });
                    
                    elements.testChime1.addEventListener('click', () => {
                        testChime();
                    });
                    
                    elements.testChime2.addEventListener('click', () => {
                        const customHour = prompt('请输入要测试的小时 (0-23):', new Date().getHours());
                        if (customHour !== null && !isNaN(customHour)) {
                            const hour = parseInt(customHour);
                            if (hour >= 0 && hour <= 23) {
                                testChime(hour);
                            } else {
                                showError('请输入0-23之间的数字');
                            }
                        }
                    });
                    
                    elements.testChime3.addEventListener('click', testChimeVolume);
                    
                    elements.saveChimeSettingsBtn.addEventListener('click', saveChimeSettings);
                    elements.resetChimeSettingsBtn.addEventListener('click', resetChimeSettings);
                    
                    // 抖音热榜相关事件
                    elements.refreshDouyinHotBtn.addEventListener('click', () => {
                        loadDouyinHotSongs(true);
                    });
                    
                    elements.douyinHotLink.addEventListener('click', (e) => {
                        e.preventDefault();
                        // 滚动到抖音热榜位置
                        elements.douyinHotSection.scrollIntoView({ behavior: 'smooth' });
                    });
                    
                    // 下载相关事件
                    elements.closeDownload.addEventListener('click', () => {
                        elements.downloadModal.classList.remove('active');
                    });
                    
                    elements.downloadCancelBtn.addEventListener('click', () => {
                        elements.downloadModal.classList.remove('active');
                    });
                    
                    elements.downloadConfirmBtn.addEventListener('click', handleDownload);

                    // 意见反馈相关事件
                    elements.closeFeedbackBtn.addEventListener('click', () => {
                        elements.feedbackModal.classList.remove('active');
                    });
                    
                    elements.feedbackCancelBtn.addEventListener('click', () => {
                        elements.feedbackModal.classList.remove('active');
                    });
                    
                    elements.feedbackForm.addEventListener('submit', handleFeedbackSubmit);
                    
                    elements.feedbackLink.addEventListener('click', (e) => {
                        e.preventDefault();
                        elements.feedbackModal.classList.add('active');
                    });

                    // 后台管理相关事件
                    elements.adminCloseBtn.addEventListener('click', () => {
                        elements.adminPanel.classList.remove('active');
                        state.isAdminPanelVisible = false;
                    });
                    
                    elements.adminTabs.forEach(tab => {
                        tab.addEventListener('click', () => {
                            const tabName = tab.dataset.tab;
                            switchAdminTab(tabName);
                        });
                    });
                    
                    elements.exportFeedbackBtn.addEventListener('click', exportFeedback);
                    elements.clearFeedbackBtn.addEventListener('click', clearFeedback);
                    elements.uploadUserDataBtn.addEventListener('click', uploadUserData);
                    elements.exportUserDataBtn.addEventListener('click', exportUserData);
                    elements.saveSettingsBtn.addEventListener('click', saveAdminSettings);
                    elements.resetSettingsBtn.addEventListener('click', resetAdminSettings);
                    
                    // Logo点击事件 - 用于进入后台
                    elements.logo.addEventListener('click', handleLogoClick);

                    // 待播放列表相关事件
                    elements.upNextToggleBtn.addEventListener('click', toggleUpNext);
                    elements.closeUpNextBtn.addEventListener('click', toggleUpNext);
                    elements.upNextLink.addEventListener('click', (e) => {
                        e.preventDefault();
                        toggleUpNext();
                    });
                    elements.clearUpNextBtn.addEventListener('click', clearUpNext);
                    elements.shuffleUpNextBtn.addEventListener('click', shuffleUpNext);

                    // 移动端菜单
                    elements.mobileMenuToggle.addEventListener('click', toggleSidebar);

                    // 点击外部关闭侧边栏
                    document.addEventListener('click', function(e) {
                        if (window.innerWidth <= 992 && 
                            elements.sidebar.classList.contains('active') && 
                            !elements.sidebar.contains(e.target) && 
                            e.target !== elements.mobileMenuToggle) {
                            toggleSidebar();
                        }
                    });

                    // 搜索功能
                    elements.searchInput.addEventListener('input', handleSearchInput);
                    elements.searchInput.addEventListener('focus', showSearchHistory);
                    document.addEventListener('click', hideSearchSuggestions);
                    
                    // 搜索历史
                    elements.clearSearchHistory.addEventListener('click', clearSearchHistoryList);

                    // 播放控制
                    elements.playBtn.addEventListener('click', togglePlay);
                    elements.prevBtn.addEventListener('click', playPrev);
                    elements.nextBtn.addEventListener('click', playNext);
                    elements.shuffleBtn.addEventListener('click', toggleShuffle);
                    elements.repeatBtn.addEventListener('click', toggleRepeat);
                    elements.playShuffleBtn.addEventListener('click', playShuffle);

                    // 收藏功能
                    elements.favoriteBtn.addEventListener('click', toggleCurrentSongFavorite);
                    elements.mobileFavoriteBtn.addEventListener('click', toggleCurrentSongFavorite);
                    elements.fullscreenFavoriteBtn.addEventListener('click', toggleCurrentSongFavorite);

                    // 移动端控制
                    elements.mobilePrevBtn.addEventListener('click', playPrev);
                    elements.mobilePlayBtn.addEventListener('click', togglePlay);
                    elements.mobileNextBtn.addEventListener('click', playNext);
                    elements.mobileLyricsBtn.addEventListener('click', toggleLyrics);

                    // 进度控制
                    elements.progressBar.addEventListener('click', seek);
                    elements.fullscreenProgressBar.addEventListener('click', fullscreenSeek);

                    // 音量控制
                    elements.volumeBtn.addEventListener('click', toggleMute);
                    elements.volumeSlider.addEventListener('input', changeVolume);

                    // 歌词面板
                    elements.toggleLyricsBtn.addEventListener('click', toggleLyrics);
                    elements.closeLyricsBtn.addEventListener('click', toggleLyrics);

                    // 主题切换
                    elements.themeToggleBtn.addEventListener('click', toggleTheme);

                    // 全屏模式
                    elements.fullscreenToggleBtn.addEventListener('click', enterFullscreen);
                    elements.fullscreenShuffleBtn.addEventListener('click', toggleShuffle);
                    elements.fullscreenPrevBtn.addEventListener('click', playPrev);
                    elements.fullscreenPlayBtn.addEventListener('click', togglePlay);
                    elements.fullscreenNextBtn.addEventListener('click', playNext);
                    elements.fullscreenRepeatBtn.addEventListener('click', toggleRepeat);
                    elements.fullscreenExitBtn.addEventListener('click', exitFullscreen);

                    // 音乐源选择
                    elements.sourceBtns.forEach(btn => {
                        btn.addEventListener('click', () => {
                            elements.sourceBtns.forEach(b => b.classList.remove('active'));
                            btn.classList.add('active');
                            state.currentSource = 'netease';
                            if (state.currentView === 'search' && elements.searchInput.value.trim()) {
                                performSearch();
                            } else if (state.currentView === 'default') {
                                loadHotSongs();
                            }
                        });
                    });

                    // 导航链接
                    setupNavigationEvents();

                    // 音频事件
                    setupAudioEvents();

                    // 页面关闭前保存状态
                    window.addEventListener('beforeunload', savePlayerState);
                    
                    // 添加触摸事件支持
                    setupTouchEvents();
                    
                    // 新增榜单相关事件
                    elements.refreshChartsBtn.addEventListener('click', (e) => {
                        e.preventDefault();
                        loadCharts(true);
                    });
                } catch (error) {
                    console.error('设置事件监听器时出错:', error);
                }
            }

            // 处理Logo点击 - 用于进入后台
            function handleLogoClick() {
                try {
                    const currentTime = new Date().getTime();
                    
                    // 检查是否在2秒内点击了3次或更多
                    if (currentTime - state.lastLogoClickTime > 2000) {
                        state.logoClickCount = 1;
                    } else {
                        state.logoClickCount++;
                    }
                    
                    state.lastLogoClickTime = currentTime;
                    
                    // 如果点击了3次或更多，显示后台面板
                    if (state.logoClickCount >= 3) {
                        showAdminPanel();
                        state.logoClickCount = 0;
                    }
                } catch (error) {
                    console.error('处理Logo点击时出错:', error);
                }
            }

            // 显示后台管理面板
            function showAdminPanel() {
                try {
                    state.isAdminPanelVisible = true;
                    elements.adminPanel.classList.add('active');
                    
                    // 加载反馈数据
                    renderAdminFeedbackList();
                    
                    // 加载用户数据
                    renderAdminUserDataList();
                } catch (error) {
                    console.error('显示后台管理面板时出错:', error);
                }
            }

            // 切换后台管理标签页
            function switchAdminTab(tabName) {
                try {
                    // 移除所有标签页的active类
                    elements.adminTabs.forEach(tab => {
                        tab.classList.remove('active');
                    });
                    
                    // 隐藏所有内容区域
                    elements.adminSections.forEach(section => {
                        section.classList.remove('active');
                    });
                    
                    // 激活选中的标签页和内容区域
                    document.querySelector(`.admin-tab[data-tab="${tabName}"]`).classList.add('active');
                    document.getElementById(`${tabName}Section`).classList.add('active');
                } catch (error) {
                    console.error('切换后台管理标签页时出错:', error);
                }
            }

            // 渲染后台反馈列表
            function renderAdminFeedbackList() {
                try {
                    if (state.feedbacks.length === 0) {
                        elements.adminFeedbackList.innerHTML = '<div class="no-lyrics"><i class="fas fa-comment-alt"></i><span>暂无用户反馈</span></div>';
                        return;
                    }
                    
                    let html = '';
                    
                    state.feedbacks.forEach(feedback => {
                        html += `
                            <div class="feedback-item">
                                <div class="feedback-header">
                                    <div class="feedback-email">${feedback.email}</div>
                                    <div class="feedback-date">${new Date(feedback.date).toLocaleString()}</div>
                                </div>
                                <div class="feedback-content">${feedback.content}</div>
                            </div>
                        `;
                    });
                    
                    elements.adminFeedbackList.innerHTML = html;
                } catch (error) {
                    console.error('渲染后台反馈列表时出错:', error);
                }
            }

            // 渲染后台用户数据列表
            function renderAdminUserDataList() {
                try {
                    if (state.userData.length === 0) {
                        elements.adminUserDataList.innerHTML = '<div class="no-lyrics"><i class="fas fa-database"></i><span>暂无用户数据</span></div>';
                        return;
                    }
                    
                    let html = '';
                    
                    state.userData.forEach((data, index) => {
                        html += `
                            <div class="user-data-item">
                                <div class="user-data-header">
                                    <div class="user-data-id">用户数据 #${index + 1}</div>
                                    <div class="user-data-date">${new Date(data.date).toLocaleString()}</div>
                                </div>
                                <div class="user-data-content">
                                    <pre>${JSON.stringify(data.data, null, 2)}</pre>
                                </div>
                            </div>
                        `;
                    });
                    
                    elements.adminUserDataList.innerHTML = html;
                } catch (error) {
                    console.error('渲染后台用户数据列表时出错:', error);
                }
            }

            // 处理意见反馈提交
            function handleFeedbackSubmit(e) {
                try {
                    e.preventDefault();
                    
                    const email = elements.feedbackEmail.value.trim();
                    const content = elements.feedbackContent.value.trim();
                    
                    if (!email || !content) {
                        showError('请填写完整的反馈信息');
                        return;
                    }
                    
                    // 创建反馈对象
                    const feedback = {
                        id: Date.now(),
                        email: email,
                        content: content,
                        date: new Date().toISOString()
                    };
                    
                    // 添加到反馈列表
                    state.feedbacks.unshift(feedback);
                    
                    // 限制反馈数量
                    if (state.feedbacks.length > state.adminSettings.maxFeedbackItems) {
                        state.feedbacks = state.feedbacks.slice(0, state.adminSettings.maxFeedbackItems);
                    }
                    
                    // 保存数据
                    saveUserData();
                    
                    // 关闭模态框
                    elements.feedbackModal.classList.remove('active');
                    
                    // 清空表单
                    elements.feedbackEmail.value = '';
                    elements.feedbackContent.value = '';
                    
                    // 显示成功消息
                    showSuccess('感谢您的反馈！');
                    
                    // 如果后台面板是打开的，更新反馈列表
                    if (state.isAdminPanelVisible) {
                        renderAdminFeedbackList();
                    }
                } catch (error) {
                    console.error('处理意见反馈提交时出错:', error);
                    showError('提交反馈失败，请重试');
                }
            }

            // 导出反馈数据
            function exportFeedback() {
                try {
                    if (state.feedbacks.length === 0) {
                        showError('没有反馈数据可导出');
                        return;
                    }
                    
                    const dataStr = JSON.stringify(state.feedbacks, null, 2);
                    const dataBlob = new Blob([dataStr], {type: 'application/json'});
                    
                    const url = URL.createObjectURL(dataBlob);
                    const link = document.createElement('a');
                    link.href = url;
                    link.download = `yueyinge_feedbacks_${new Date().toISOString().slice(0, 10)}.json`;
                    document.body.appendChild(link);
                    link.click();
                    document.body.removeChild(link);
                    URL.revokeObjectURL(url);
                    
                    showSuccess('反馈数据导出成功');
                } catch (error) {
                    console.error('导出反馈数据时出错:', error);
                    showError('导出反馈数据失败');
                }
            }

            // 清空反馈数据
            function clearFeedback() {
                try {
                    if (confirm('确定要清空所有反馈数据吗？此操作不可撤销。')) {
                        state.feedbacks = [];
                        saveUserData();
                        renderAdminFeedbackList();
                        showSuccess('反馈数据已清空');
                    }
                } catch (error) {
                    console.error('清空反馈数据时出错:', error);
                    showError('清空反馈数据失败');
                }
            }

            // 上传用户数据
            function uploadUserData() {
                try {
                    const input = document.createElement('input');
                    input.type = 'file';
                    input.accept = '.json';
                    
                    input.onchange = e => {
                        const file = e.target.files[0];
                        if (!file) return;
                        
                        const reader = new FileReader();
                        reader.onload = event => {
                            try {
                                const data = JSON.parse(event.target.result);
                                
                                if (Array.isArray(data)) {
                                    // 合并数据
                                    state.userData = [...data, ...state.userData];
                                    
                                    // 限制数据数量
                                    if (state.userData.length > 100) {
                                        state.userData = state.userData.slice(0, 100);
                                    }
                                    
                                    saveUserData();
                                    renderAdminUserDataList();
                                    showSuccess('用户数据上传成功');
                                } else {
                                    showError('文件格式不正确');
                                }
                            } catch (error) {
                                console.error('解析用户数据文件时出错:', error);
                                showError('文件格式不正确');
                            }
                        };
                        
                        reader.readAsText(file);
                    };
                    
                    input.click();
                } catch (error) {
                    console.error('上传用户数据时出错:', error);
                    showError('上传用户数据失败');
                }
            }

            // 导出用户数据
            function exportUserData() {
                try {
                    if (state.userData.length === 0) {
                        showError('没有用户数据可导出');
                        return;
                    }
                    
                    const dataStr = JSON.stringify(state.userData, null, 2);
                    const dataBlob = new Blob([dataStr], {type: 'application/json'});
                    
                    const url = URL.createObjectURL(dataBlob);
                    const link = document.createElement('a');
                    link.href = url;
                    link.download = `yueyinge_user_data_${new Date().toISOString().slice(0, 10)}.json`;
                    document.body.appendChild(link);
                    link.click();
                    document.body.removeChild(link);
                    URL.revokeObjectURL(url);
                    
                    showSuccess('用户数据导出成功');
                } catch (error) {
                    console.error('导出用户数据时出错:', error);
                    showError('导出用户数据失败');
                }
            }

            // 更新后台设置UI
            function updateAdminSettingsUI() {
                try {
                    elements.autoUploadInterval.value = state.adminSettings.autoUploadInterval;
                    elements.maxFeedbackItems.value = state.adminSettings.maxFeedbackItems;
                } catch (error) {
                    console.error('更新后台设置UI时出错:', error);
                }
            }

            // 保存后台设置
            function saveAdminSettings() {
                try {
                    state.adminSettings.autoUploadInterval = parseInt(elements.autoUploadInterval.value);
                    state.adminSettings.maxFeedbackItems = parseInt(elements.maxFeedbackItems.value);
                    
                    saveUserData();
                    
                    // 重启自动上传定时器
                    startAutoUploadTimer();
                    
                    showSuccess('设置保存成功');
                } catch (error) {
                    console.error('保存后台设置时出错:', error);
                    showError('保存设置失败');
                }
            }

            // 重置后台设置
            function resetAdminSettings() {
                try {
                    state.adminSettings = {
                        autoUploadInterval: 5,
                        maxFeedbackItems: 100
                    };
                    
                    updateAdminSettingsUI();
                    saveUserData();
                    
                    // 重启自动上传定时器
                    startAutoUploadTimer();
                    
                    showSuccess('设置已恢复默认');
                } catch (error) {
                    console.error('重置后台设置时出错:', error);
                    showError('重置设置失败');
                }
            }

            // 启动自动上传定时器
            function startAutoUploadTimer() {
                try {
                    // 清除现有定时器
                    if (state.autoUploadTimer) {
                        clearInterval(state.autoUploadTimer);
                    }
                    
                    // 设置新的定时器
                    const interval = state.adminSettings.autoUploadInterval * 60 * 1000;
                    state.autoUploadTimer = setInterval(() => {
                        autoUploadUserData();
                    }, interval);
                } catch (error) {
                    console.error('启动自动上传定时器时出错:', error);
                }
            }

            // 自动上传用户数据
            function autoUploadUserData() {
                try {
                    // 创建用户数据快照
                    const userDataSnapshot = {
                        date: new Date().toISOString(),
                        data: {
                            playHistory: state.playHistory,
                            searchHistory: state.searchHistory,
                            favoriteMusic: state.favoriteMusic,
                            downloads: state.downloads,
                            upNextSongs: state.upNextSongs
                        }
                    };
                    
                    // 添加到用户数据列表
                    state.userData.unshift(userDataSnapshot);
                    
                    // 限制数据数量
                    if (state.userData.length > 100) {
                        state.userData = state.userData.slice(0, 100);
                    }
                    
                    // 保存数据
                    saveUserData();
                    
                    console.log('用户数据已自动上传');
                } catch (error) {
                    console.error('自动上传用户数据时出错:', error);
                }
            }

            // 设置触摸事件
            function setupTouchEvents() {
                try {
                    // 修复移动端进度条拖动问题
                    elements.progressBar.addEventListener('touchstart', handleTouchProgress);
                    elements.fullscreenProgressBar.addEventListener('touchstart', handleTouchProgress);
                    
                    // 添加移动端滑动支持
                    let startX = 0;
                    let startY = 0;
                    
                    document.addEventListener('touchstart', function(e) {
                        startX = e.touches[0].clientX;
                        startY = e.touches[0].clientY;
                    });
                    
                    document.addEventListener('touchend', function(e) {
                        if (!startX || !startY) return;
                        
                        const endX = e.changedTouches[0].clientX;
                        const endY = e.changedTouches[0].clientY;
                        
                        const diffX = startX - endX;
                        const diffY = startY - endY;
                        
                        // 水平滑动大于垂直滑动，且滑动距离大于50px
                        if (Math.abs(diffX) > Math.abs(diffY) && Math.abs(diffX) > 50) {
                            if (diffX > 0) {
                                // 向左滑动 - 下一首
                                playNext();
                            } else {
                                // 向右滑动 - 上一首
                                playPrev();
                            }
                        }
                        
                        startX = 0;
                        startY = 0;
                    });
                } catch (error) {
                    console.error('设置触摸事件时出错:', error);
                }
            }

            // 处理触摸进度条
            function handleTouchProgress(e) {
                try {
                    const progressBar = e.currentTarget;
                    const rect = progressBar.getBoundingClientRect();
                    const touch = e.touches[0];
                    const percent = (touch.clientX - rect.left) / rect.width;
                    
                    if (progressBar === elements.progressBar) {
                        seek(e);
                    } else if (progressBar === elements.fullscreenProgressBar) {
                        fullscreenSeek(e);
                    }
                } catch (error) {
                    console.error('处理触摸进度条时出错:', error);
                }
            }

            // 设置导航事件
            function setupNavigationEvents() {
                try {
                    // 首页
                    elements.homeLink.addEventListener('click', (e) => {
                        e.preventDefault();
                        state.currentView = 'default';
                        updateActiveNavLink(elements.homeLink);
                        loadHotSongs();
                    });
                    
                    // 搜索
                    elements.searchLink.addEventListener('click', (e) => {
                        e.preventDefault();
                        state.currentView = 'search';
                        updateActiveNavLink(elements.searchLink);
                        elements.searchInput.focus();
                    });
                    
                    // 我的音乐库
                    elements.myMusicLibraryLink.addEventListener('click', (e) => {
                        e.preventDefault();
                        state.currentView = 'library';
                        updateActiveNavLink(elements.myMusicLibraryLink);
                        showMyMusicLibrary();
                    });
                    
                    // 下载管理
                    elements.downloadsLink.addEventListener('click', (e) => {
                        e.preventDefault();
                        state.currentView = 'downloads';
                        updateActiveNavLink(elements.downloadsLink);
                        showDownloads();
                    });
                    
                    elements.downloadManagementLink.addEventListener('click', (e) => {
                        e.preventDefault();
                        state.currentView = 'downloads';
                        updateActiveNavLink(elements.downloadManagementLink);
                        showDownloads();
                    });
                    
                    // 我喜欢的音乐
                    elements.favoriteMusicLink.addEventListener('click', (e) => {
                        e.preventDefault();
                        state.currentView = 'favorites';
                        updateActiveNavLink(elements.favoriteMusicLink);
                        showFavoriteMusic();
                    });
                    
                    // 播放历史
                    elements.playHistoryLink.addEventListener('click', (e) => {
                        e.preventDefault();
                        state.currentView = 'history';
                        updateActiveNavLink(elements.playHistoryLink);
                        showPlayHistory();
                    });
                    
                    // 热门歌单
                    elements.hotPlaylistLink1.addEventListener('click', (e) => {
                        e.preventDefault();
                        loadHotSongs();
                    });
                    
                    elements.hotPlaylistLink2.addEventListener('click', (e) => {
                        e.preventDefault();
                        loadNewSongs();
                    });
                    
                    elements.hotPlaylistLink3.addEventListener('click', (e) => {
                        e.preventDefault();
                        loadRisingSongs();
                    });
                    
                    elements.hotPlaylistLink4.addEventListener('click', (e) => {
                        e.preventDefault();
                        loadOriginalSongs();
                    });
                    
                    // 抖音热榜
                    elements.douyinHotLink.addEventListener('click', (e) => {
                        e.preventDefault();
                        // 滚动到抖音热榜位置
                        elements.douyinHotSection.scrollIntoView({ behavior: 'smooth' });
                    });
                } catch (error) {
                    console.error('设置导航事件时出错:', error);
                }
            }

            // 更新活动导航链接
            function updateActiveNavLink(activeLink) {
                try {
                    document.querySelectorAll('.nav-links a').forEach(link => {
                        link.classList.remove('active');
                    });
                    activeLink.classList.add('active');
                } catch (error) {
                    console.error('更新活动导航链接时出错:', error);
                }
            }

            // 设置音频事件
            function setupAudioEvents() {
                try {
                    state.audioPlayer.addEventListener('timeupdate', updateProgress);
                    state.audioPlayer.addEventListener('loadedmetadata', () => {
                        state.duration = state.audioPlayer.duration;
                        elements.duration.textContent = formatTime(state.duration);
                        elements.fullscreenDuration.textContent = formatTime(state.duration);
                    });
                    state.audioPlayer.addEventListener('ended', handleSongEnd);
                    state.audioPlayer.addEventListener('error', handleAudioError);
                    state.audioPlayer.addEventListener('loadstart', () => {
                        state.isAudioLoading = true;
                    });
                    state.audioPlayer.addEventListener('canplay', () => {
                        state.isAudioLoading = false;
                    });
                } catch (error) {
                    console.error('设置音频事件时出错:', error);
                }
            }

            // 切换侧边栏
            function toggleSidebar() {
                try {
                    elements.sidebar.classList.toggle('active');
                } catch (error) {
                    console.error('切换侧边栏时出错:', error);
                }
            }

            // 处理搜索输入
            function handleSearchInput() {
                try {
                    const query = elements.searchInput.value.trim();
                    
                    if (query.length > 0) {
                        generateSearchSuggestions(query);
                        elements.searchSuggestions.style.display = 'block';
                        elements.searchHistory.style.display = 'none';
                    } else {
                        elements.searchSuggestions.style.display = 'none';
                    }
                } catch (error) {
                    console.error('处理搜索输入时出错:', error);
                }
            }

            // 生成搜索建议
            function generateSearchSuggestions(query) {
                try {
                    // 清空之前的建议
                    elements.searchSuggestions.innerHTML = '';
                    
                    // 从搜索历史中查找相关建议
                    const relatedHistory = state.searchHistory
                        .filter(item => item.toLowerCase().includes(query.toLowerCase()))
                        .slice(0, 5);
                    
                    // 生成搜索建议
                    const suggestions = [
                        { icon: 'fas fa-music', text: `歌曲: ${query}`, type: 'song' },
                        { icon: 'fas fa-user', text: `歌手: ${query}`, type: 'artist' }
                    ];
                    
                    // 添加历史建议
                    relatedHistory.forEach(item => {
                        suggestions.push({ 
                            icon: 'fas fa-history', 
                            text: item, 
                            type: 'history',
                            isHistory: true 
                        });
                    });
                    
                    // 渲染建议
                    suggestions.forEach(suggestion => {
                        const suggestionElement = document.createElement('div');
                        suggestionElement.className = 'search-suggestion';
                        suggestionElement.innerHTML = `
                            <i class="${suggestion.icon}"></i>
                            <span>${suggestion.text}</span>
                        `;
                        suggestionElement.addEventListener('click', () => {
                            if (suggestion.isHistory) {
                                elements.searchInput.value = suggestion.text;
                            } else {
                                elements.searchInput.value = query;
                            }
                            performSearch();
                            elements.searchSuggestions.style.display = 'none';
                        });
                        elements.searchSuggestions.appendChild(suggestionElement);
                    });
                } catch (error) {
                    console.error('生成搜索建议时出错:', error);
                }
            }

            // 显示搜索历史
            function showSearchHistory() {
                try {
                    if (elements.searchInput.value.trim() === '' && state.searchHistory.length > 0) {
                        elements.searchHistory.style.display = 'block';
                        elements.searchSuggestions.style.display = 'none';
                    }
                } catch (error) {
                    console.error('显示搜索历史时出错:', error);
                }
            }

            // 隐藏搜索建议
            function hideSearchSuggestions(e) {
                try {
                    if (!elements.searchContainer.contains(e.target)) {
                        elements.searchSuggestions.style.display = 'none';
                        elements.searchHistory.style.display = 'none';
                    }
                } catch (error) {
                    console.error('隐藏搜索建议时出错:', error);
                }
            }

            // 更新搜索历史UI
            function updateSearchHistoryUI() {
                try {
                    elements.searchHistoryList.innerHTML = '';
                    
                    state.searchHistory.slice(0, 10).forEach(item => {
                        const historyItem = document.createElement('div');
                        historyItem.className = 'search-history-item';
                        historyItem.innerHTML = `
                            <div class="search-history-text">
                                <i class="fas fa-history"></i>
                                <span>${item}</span>
                            </div>
                            <button class="delete-search-item" data-query="${item}">
                                <i class="fas fa-times"></i>
                            </button>
                        `;
                        
                        historyItem.addEventListener('click', () => {
                            elements.searchInput.value = item;
                            performSearch();
                            elements.searchHistory.style.display = 'none';
                        });
                        
                        const deleteBtn = historyItem.querySelector('.delete-search-item');
                        deleteBtn.addEventListener('click', (e) => {
                            e.stopPropagation();
                            deleteSearchHistoryItem(item);
                        });
                        
                        elements.searchHistoryList.appendChild(historyItem);
                    });
                } catch (error) {
                    console.error('更新搜索历史UI时出错:', error);
                }
            }

            // 删除搜索历史项
            function deleteSearchHistoryItem(query) {
                try {
                    state.searchHistory = state.searchHistory.filter(item => item !== query);
                    saveUserData();
                    updateSearchHistoryUI();
                } catch (error) {
                    console.error('删除搜索历史项时出错:', error);
                }
            }

            // 清空搜索历史
            function clearSearchHistoryList() {
                try {
                    state.searchHistory = [];
                    saveUserData();
                    updateSearchHistoryUI();
                } catch (error) {
                    console.error('清空搜索历史时出错:', error);
                }
            }

            // 执行搜索 - 使用多API系统
            function performSearch() {
                try {
                    const query = elements.searchInput.value.trim();
                    if (!query) return;
                    
                    // 添加到搜索历史
                    if (!state.searchHistory.includes(query)) {
                        state.searchHistory.unshift(query);
                        // 限制历史记录数量
                        if (state.searchHistory.length > 20) {
                            state.searchHistory.pop();
                        }
                        saveUserData();
                        updateSearchHistoryUI();
                    }
                    
                    state.currentView = 'search';
                    elements.playlistTitle.textContent = `搜索结果: ${query}`;
                    
                    showLoading();
                    
                    // 使用当前选择的API进行搜索
                    const searchUrl = getSearchUrl(query, 30);
                    
                    console.log('搜索URL:', searchUrl);
                    
                    fetch(searchUrl)
                        .then(response => {
                            if (!response.ok) {
                                throw new Error(`HTTP error! status: ${response.status}`);
                            }
                            return response.json();
                        })
                        .then(data => {
                            hideLoading();
                            
                            const songs = processSearchResponse(data);
                            
                            if (songs.length > 0) {
                                state.songs = songs;
                                renderSongList(songs);
                                state.apiStatus[state.currentApi] = 'online';
                            } else {
                                showError('未找到相关歌曲');
                            }
                            
                            updateApiStatusDisplay();
                        })
                        .catch(error => {
                            hideLoading();
                            console.error('搜索失败:', error);
                            
                            // 如果当前API失败，自动切换到另一个API
                            if (state.apiSettings.autoSwitch) {
                                const otherApis = Object.keys(API_CONFIG).filter(api => api !== state.currentApi && api !== 'douyinHot');
                                let nextApiIndex = 0;
                                
                                const tryNextApi = () => {
                                    if (nextApiIndex >= otherApis.length) {
                                        showError('所有API都搜索失败，请检查网络连接或稍后重试');
                                        return;
                                    }
                                    
                                    const nextApi = otherApis[nextApiIndex];
                                    showError(`搜索失败，正在切换到${API_CONFIG[nextApi].name}...`);
                                    switchApi(nextApi);
                                    
                                    // 重新尝试搜索
                                    setTimeout(() => {
                                        performSearch();
                                    }, 1000);
                                    
                                    nextApiIndex++;
                                };
                                
                                tryNextApi();
                            } else {
                                showError('搜索失败，请检查网络连接或稍后重试');
                            }
                        });
                } catch (error) {
                    hideLoading();
                    console.error('执行搜索时出错:', error);
                    showError('搜索失败，请稍后重试');
                }
            }

            // 显示我的音乐库
            function showMyMusicLibrary() {
                try {
                    elements.playlistTitle.textContent = '我的音乐库';
                    
                    if (state.myMusicLibrary.length === 0) {
                        elements.songList.innerHTML = `
                            <div class="no-lyrics">
                                <i class="fas fa-layer-group"></i>
                                <div>音乐库为空</div>
                                <p>你添加到音乐库的歌曲将显示在这里</p>
                            </div>
                        `;
                    } else {
                        renderSongList(state.myMusicLibrary);
                    }
                } catch (error) {
                    console.error('显示我的音乐库时出错:', error);
                    showError('加载音乐库失败');
                }
            }

            // 显示下载管理
            function showDownloads() {
                try {
                    elements.playlistTitle.textContent = '下载管理';
                    
                    if (state.downloads.length === 0) {
                        elements.songList.innerHTML = `
                            <div class="no-lyrics">
                                <i class="fas fa-download"></i>
                                <div>暂无下载内容</div>
                                <p>你下载的歌曲将显示在这里</p>
                            </div>
                        `;
                    } else {
                        renderDownloadList();
                    }
                } catch (error) {
                    console.error('显示下载管理时出错:', error);
                    showError('加载下载列表失败');
                }
            }

            // 显示我喜欢的音乐
            function showFavoriteMusic() {
                try {
                    elements.playlistTitle.textContent = '我喜欢的音乐';
                    
                    if (state.favoriteMusic.length === 0) {
                        elements.songList.innerHTML = `
                            <div class="no-lyrics">
                                <i class="fas fa-heart"></i>
                                <div>暂无喜欢的音乐</div>
                                <p>你喜欢的歌曲将显示在这里</p>
                            </div>
                        `;
                    } else {
                        renderSongList(state.favoriteMusic);
                        state.songs = state.favoriteMusic;
                        state.currentSongIndex = -1;
                        updateFavoriteButtonState();
                        updateAllPlayButtons();
                        state.isPlaying = false;
                    }
                } catch (error) {
                    console.error('显示我喜欢的音乐时出错:', error);
                    showError('加载喜欢的音乐失败');
                }
            }

            // 显示播放历史
            function showPlayHistory() {
                try {
                    elements.playlistTitle.textContent = '播放历史';
                    
                    if (state.playHistory.length === 0) {
                        elements.songList.innerHTML = `
                            <div class="no-lyrics">
                                <i class="fas fa-history"></i>
                                <div>暂无播放历史</div>
                                <p>你播放过的歌曲将显示在这里</p>
                            </div>
                        `;
                    } else {
                        renderSongList(state.playHistory);
                        state.songs = state.playHistory;
                        state.currentSongIndex = -1;
                        updateFavoriteButtonState();
                        updateAllPlayButtons();
                        state.isPlaying = false;
                    }
                } catch (error) {
                    console.error('显示播放历史时出错:', error);
                    showError('加载播放历史失败');
                }
            }

            // 渲染下载列表
            function renderDownloadList() {
                try {
                    let html = '';
                    
                    state.downloads.forEach((download, index) => {
                        html += `
                            <div class="song-item">
                                <div class="song-number">${index + 1}</div>
                                <div class="song-info">
                                    <div class="song-name">${download.name}</div>
                                    <div class="song-artist">${download.artist}</div>
                                </div>
                                <div class="song-duration">${download.size || '未知'}</div>
                                <div class="song-actions">
                                    <button class="song-action-btn play-download-btn" data-index="${index}">
                                        <i class="fas fa-play"></i>
                                    </button>
                                    <button class="song-action-btn delete-download-btn" data-index="${index}">
                                        <i class="fas fa-trash"></i>
                                    </button>
                                </div>
                            </div>
                        `;
                    });
                    
                    elements.songList.innerHTML = html;
                    
                    // 添加事件监听器
                    document.querySelectorAll('.play-download-btn').forEach(btn => {
                        btn.addEventListener('click', (e) => {
                            e.stopPropagation();
                            const index = parseInt(btn.dataset.index);
                            playDownloadedSong(index);
                        });
                    });
                    
                    document.querySelectorAll('.delete-download-btn').forEach(btn => {
                        btn.addEventListener('click', (e) => {
                            e.stopPropagation();
                            const index = parseInt(btn.dataset.index);
                            deleteDownloadedSong(index);
                        });
                    });
                } catch (error) {
                    console.error('渲染下载列表时出错:', error);
                }
            }

            // 播放下载的歌曲
            function playDownloadedSong(index) {
                try {
                    const download = state.downloads[index];
                    
                    // 创建临时歌曲对象
                    const song = {
                        name: download.name,
                        artist: download.artist,
                        url: download.url,
                        picurl: download.picurl,
                        source: download.source,
                        id: download.id,
                        album: download.album
                    };
                    
                    // 播放歌曲
                    playSong(song, -1, state.downloads);
                } catch (error) {
                    console.error('播放下载的歌曲时出错:', error);
                    showError('播放下载的歌曲失败');
                }
            }

            // 删除下载的歌曲
            function deleteDownloadedSong(index) {
                try {
                    if (confirm('确定要删除这首下载的歌曲吗？')) {
                        state.downloads.splice(index, 1);
                        saveUserData();
                        showDownloads();
                        showSuccess('歌曲已从下载列表中删除');
                    }
                } catch (error) {
                    console.error('删除下载的歌曲时出错:', error);
                    showError('删除下载的歌曲失败');
                }
            }

            // 加载热门歌曲
            function loadHotSongs() {
                try {
                    state.currentView = 'default';
                    elements.playlistTitle.textContent = '热门推荐';
                    
                    showLoading();
                    
                    // 使用当前API搜索热门歌曲
                    const url = getSearchUrl('热门', 30);
                    
                    fetch(url)
                        .then(response => {
                            if (!response.ok) {
                                throw new Error(`HTTP error! status: ${response.status}`);
                            }
                            return response.json();
                        })
                        .then(data => {
                            hideLoading();
                            
                            const songs = processSearchResponse(data);
                            
                            if (songs.length > 0) {
                                state.songs = songs;
                                renderSongList(songs);
                                state.apiStatus[state.currentApi] = 'online';
                            } else {
                                // 备用方案：使用默认热门歌曲
                                loadDefaultHotSongs();
                            }
                            
                            updateApiStatusDisplay();
                        })
                        .catch(error => {
                            hideLoading();
                            console.error('加载热门歌曲失败:', error);
                            // 备用方案：使用默认热门歌曲
                            loadDefaultHotSongs();
                        });
                } catch (error) {
                    hideLoading();
                    console.error('加载热门歌曲时出错:', error);
                    loadDefaultHotSongs();
                }
            }

            // 加载默认热门歌曲
            function loadDefaultHotSongs() {
                try {
                    // 使用一些默认的热门歌曲
                    const defaultSongs = [
                        {
                            name: '起风了',
                            artist: '买辣椒也用券',
                            id: '1330348068',
                            source: 'netease'
                        },
                        {
                            name: '晴天',
                            artist: '周杰伦',
                            id: '186016',
                            source: 'netease'
                        },
                        {
                            name: '光年之外',
                            artist: 'G.E.M.邓紫棋',
                            id: '449818741',
                            source: 'netease'
                        },
                        {
                            name: '年少有为',
                            artist: '李荣浩',
                            id: '1293886117',
                            source: 'netease'
                        },
                        {
                            name: '演员',
                            artist: '薛之谦',
                            id: '32507038',
                            source: 'netease'
                        }
                    ];
                    
                    state.songs = defaultSongs;
                    renderSongList(defaultSongs);
                } catch (error) {
                    console.error('加载默认热门歌曲时出错:', error);
                    showError('加载歌曲失败，请检查网络连接');
                }
            }

            // 加载新歌
            function loadNewSongs() {
                try {
                    state.currentView = 'default';
                    elements.playlistTitle.textContent = '新歌推荐';
                    
                    showLoading();
                    
                    // 使用当前API搜索新歌
                    const url = getSearchUrl('新歌', 30);
                    
                    fetch(url)
                        .then(response => {
                            if (!response.ok) {
                                throw new Error(`HTTP error! status: ${response.status}`);
                            }
                            return response.json();
                        })
                        .then(data => {
                            hideLoading();
                            
                            const songs = processSearchResponse(data);
                            
                            if (songs.length > 0) {
                                state.songs = songs;
                                renderSongList(songs);
                                state.apiStatus[state.currentApi] = 'online';
                            } else {
                                showError('加载新歌失败');
                            }
                            
                            updateApiStatusDisplay();
                        })
                        .catch(error => {
                            hideLoading();
                            console.error('加载新歌失败:', error);
                            showError('加载新歌失败，请检查网络连接');
                        });
                } catch (error) {
                    hideLoading();
                    console.error('加载新歌时出错:', error);
                    showError('加载新歌失败');
                }
            }

            // 加载飙升歌曲
            function loadRisingSongs() {
                try {
                    state.currentView = 'default';
                    elements.playlistTitle.textContent = '飙升推荐';
                    
                    showLoading();
                    
                    // 使用当前API搜索飙升歌曲
                    const url = getSearchUrl('飙升', 30);
                    
                    fetch(url)
                        .then(response => {
                            if (!response.ok) {
                                throw new Error(`HTTP error! status: ${response.status}`);
                            }
                            return response.json();
                        })
                        .then(data => {
                            hideLoading();
                            
                            const songs = processSearchResponse(data);
                            
                            if (songs.length > 0) {
                                state.songs = songs;
                                renderSongList(songs);
                                state.apiStatus[state.currentApi] = 'online';
                            } else {
                                showError('加载飙升歌曲失败');
                            }
                            
                            updateApiStatusDisplay();
                        })
                        .catch(error => {
                            hideLoading();
                            console.error('加载飙升歌曲失败:', error);
                            showError('加载飙升歌曲失败，请检查网络连接');
                        });
                } catch (error) {
                    hideLoading();
                    console.error('加载飙升歌曲时出错:', error);
                    showError('加载飙升歌曲失败');
                }
            }

            // 加载原创歌曲
            function loadOriginalSongs() {
                try {
                    state.currentView = 'default';
                    elements.playlistTitle.textContent = '原创推荐';
                    
                    showLoading();
                    
                    // 使用当前API搜索原创歌曲
                    const url = getSearchUrl('原创', 30);
                    
                    fetch(url)
                        .then(response => {
                            if (!response.ok) {
                                throw new Error(`HTTP error! status: ${response.status}`);
                            }
                            return response.json();
                        })
                        .then(data => {
                            hideLoading();
                            
                            const songs = processSearchResponse(data);
                            
                            if (songs.length > 0) {
                                state.songs = songs;
                                renderSongList(songs);
                                state.apiStatus[state.currentApi] = 'online';
                            } else {
                                showError('加载原创歌曲失败');
                            }
                            
                            updateApiStatusDisplay();
                        })
                        .catch(error => {
                            hideLoading();
                            console.error('加载原创歌曲失败:', error);
                            showError('加载原创歌曲失败，请检查网络连接');
                        });
                } catch (error) {
                    hideLoading();
                    console.error('加载原创歌曲时出错:', error);
                    showError('加载原创歌曲失败');
                }
            }

            // 加载热榜歌单
            function loadHotPlaylist() {
                try {
                    // 模拟一些热榜歌单数据
                    const hotPlaylists = [
                        {
                            title: '热歌榜',
                            description: '最新热门歌曲合集',
                            type: 'hot'
                        },
                        {
                            title: '新歌榜',
                            description: '最新发布歌曲推荐',
                            type: 'new'
                        },
                        {
                            title: '飙升榜',
                            description: '近期热度飙升歌曲',
                            type: 'rising'
                        },
                        {
                            title: '原创榜',
                            description: '优秀原创音乐作品',
                            type: 'original'
                        },
                        {
                            title: '抖音热榜',
                            description: '抖音热门歌曲',
                            type: 'douyinHot'
                        }
                    ];
                    
                    let html = '';
                    
                    hotPlaylists.forEach(playlist => {
                        html += `
                            <div class="card" data-type="${playlist.type}">
                                <div class="card-image">
                                    <i class="${playlist.type === 'douyinHot' ? 'fab fa-tiktok' : 'fas fa-fire'}" style="font-size: 48px;"></i>
                                </div>
                                <div class="card-title">${playlist.title}</div>
                                <div class="card-description">${playlist.description}</div>
                                <div class="card-play-btn">
                                    <i class="fas fa-play"></i>
                                </div>
                            </div>
                        `;
                    });
                    
                    elements.hotPlaylist.innerHTML = html;
                    
                    // 添加点击事件
                    document.querySelectorAll('#hotPlaylist .card').forEach(card => {
                        card.addEventListener('click', () => {
                            const type = card.dataset.type;
                            
                            switch (type) {
                                case 'hot':
                                    loadHotSongs();
                                    break;
                                case 'new':
                                    loadNewSongs();
                                    break;
                                case 'rising':
                                    loadRisingSongs();
                                    break;
                                case 'original':
                                    loadOriginalSongs();
                                    break;
                                case 'douyinHot':
                                    // 滚动到抖音热榜位置
                                    elements.douyinHotSection.scrollIntoView({ behavior: 'smooth' });
                                    break;
                            }
                        });
                    });
                } catch (error) {
                    console.error('加载热榜歌单时出错:', error);
                }
            }

            // 渲染歌曲列表
            function renderSongList(songs) {
                try {
                    if (!songs || songs.length === 0) {
                        elements.songList.innerHTML = `
                            <div class="no-lyrics">
                                <i class="fas fa-music"></i>
                                <div>暂无歌曲</div>
                            </div>
                        `;
                        return;
                    }
                    
                    let html = '';
                    
                    songs.forEach((song, index) => {
                        const isActive = state.currentSongIndex === index && state.isPlaying;
                        const isFavorited = state.favoriteMusic.some(fav => 
                            fav.id === song.id && fav.source === song.source
                        );
                        
                        html += `
                            <div class="song-item ${isActive ? 'active' : ''}" data-index="${index}">
                                <div class="song-number">${index + 1}</div>
                                <div class="song-info">
                                    <div class="song-name">${song.name} ${song.isPaid ? '<span class="paid-song-indicator">VIP</span>' : ''}</div>
                                    <div class="song-artist">${song.artistsname || song.artist}</div>
                                </div>
                                <div class="song-duration">${song.duration ? formatTime(song.duration / 1000) : '--:--'}</div>
                                <div class="song-actions">
                                    <button class="song-action-btn ${isFavorited ? 'favorited' : ''}" data-action="favorite" data-index="${index}">
                                        <i class="fas fa-heart"></i>
                                    </button>
                                    <button class="song-action-btn" data-action="add-to-upnext" data-index="${index}">
                                        <i class="fas fa-plus"></i>
                                    </button>
                                    <button class="song-action-btn" data-action="download" data-index="${index}">
                                        <i class="fas fa-download"></i>
                                    </button>
                                </div>
                            </div>
                        `;
                    });
                    
                    elements.songList.innerHTML = html;
                    
                    // 添加歌曲点击事件
                    document.querySelectorAll('.song-item').forEach(item => {
                        item.addEventListener('click', (e) => {
                            if (!e.target.closest('.song-actions')) {
                                const index = parseInt(item.dataset.index);
                                playSong(songs[index], index, songs);
                            }
                        });
                    });
                    
                    // 添加按钮点击事件
                    document.querySelectorAll('.song-action-btn').forEach(btn => {
                        btn.addEventListener('click', (e) => {
                            e.stopPropagation();
                            const action = btn.dataset.action;
                            const index = parseInt(btn.dataset.index);
                            const song = songs[index];
                            
                            switch (action) {
                                case 'favorite':
                                    toggleFavorite(song, index);
                                    break;
                                case 'add-to-upnext':
                                    addToUpNext(song);
                                    break;
                                case 'download':
                                    showDownloadOptions(song);
                                    break;
                            }
                        });
                    });
                } catch (error) {
                    console.error('渲染歌曲列表时出错:', error);
                }
            }

            // 播放歌曲 - 使用多API系统，修复播放问题
            function playSong(song, index, songList = null) {
                try {
                    if (songList) {
                        state.songs = songList;
                    }
                    
                    state.currentSongIndex = index;
                    state.isPlaying = false;
                    
                    updatePlayerUI(song);
                    updateAllPlayButtons();
                    
                    // 添加到播放历史
                    addToPlayHistory(song);
                    
                    // 加载歌词
                    loadLyrics(song);
                    
                    // 对于抖音和汽水API，播放链接已经在搜索时获取
                    if ((state.currentApi === 'douyin' || state.currentApi === 'qishui') && song.url) {
                        state.audioPlayer.src = song.url;
                        state.audioPlayer.load();
                        
                        state.audioPlayer.play().then(() => {
                            state.isPlaying = true;
                            updateAllPlayButtons();
                            
                            // 更新歌曲列表中的活动状态
                            updateSongListActiveState();
                            
                            state.apiStatus[state.currentApi] = 'online';
                            updateApiStatusDisplay();
                        }).catch(error => {
                            console.error('播放失败:', error);
                            showError('播放失败，请尝试其他歌曲');
                            state.isPlaying = false;
                            updateAllPlayButtons();
                        });
                    } else {
                        // 获取歌曲URL - 使用当前API
                        getSongUrl(song).then(songData => {
                            if (songData && songData.url) {
                                state.audioPlayer.src = songData.url;
                                state.audioPlayer.load();
                                
                                // 更新歌曲信息（包含专辑封面等）
                                if (songData.picurl) {
                                    song.picurl = songData.picurl;
                                    updateAlbumArt(songData.picurl, song.album);
                                }
                                
                                state.audioPlayer.play().then(() => {
                                    state.isPlaying = true;
                                    updateAllPlayButtons();
                                    
                                    // 更新歌曲列表中的活动状态
                                    updateSongListActiveState();
                                    
                                    state.apiStatus[state.currentApi] = 'online';
                                    updateApiStatusDisplay();
                                }).catch(error => {
                                    console.error('播放失败:', error);
                                    showError('播放失败，请尝试其他歌曲');
                                    state.isPlaying = false;
                                    updateAllPlayButtons();
                                });
                            } else {
                                showError('无法获取歌曲播放地址');
                            }
                        }).catch(error => {
                            console.error('获取歌曲URL失败:', error);
                            showError('获取歌曲播放地址失败');
                        });
                    }
                } catch (error) {
                    console.error('播放歌曲时出错:', error);
                    showError('播放歌曲失败');
                }
            }

            // 获取歌曲URL - 使用多API系统，修复主用API和备用API的问题
            function getSongUrl(song) {
                return new Promise((resolve, reject) => {
                    try {
                        const url = getMusicUrl(song.id, song);
                        
                        if (state.currentApi === 'douyin' || state.currentApi === 'qishui') {
                            // 抖音和汽水API不需要再次请求，直接返回歌曲数据
                            resolve({
                                url: song.url,
                                picurl: song.picurl
                            });
                        } else {
                            fetch(url)
                                .then(response => {
                                    if (!response.ok) {
                                        throw new Error(`HTTP error! status: ${response.status}`);
                                    }
                                    return response.json();
                                })
                                .then(data => {
                                    const songData = processMusicUrlResponse(data);
                                    if (songData) {
                                        resolve(songData);
                                    } else {
                                        reject(new Error('无法获取歌曲信息'));
                                    }
                                })
                                .catch(error => {
                                    reject(error);
                                });
                        }
                    } catch (error) {
                        reject(error);
                    }
                });
            }

            // 加载歌词 - 使用多API系统
            function loadLyrics(song) {
                try {
                    if (!song.id) {
                        resetLyrics();
                        return;
                    }
                    
                    // 对于抖音和汽水API，歌词已经在搜索时获取
                    if ((state.currentApi === 'douyin' || state.currentApi === 'qishui') && song.lrc) {
                        parseLyrics(song.lrc);
                        state.apiStatus[state.currentApi] = 'online';
                        updateApiStatusDisplay();
                        return;
                    }
                    
                    const url = getLyricsUrl(song.id, song);
                    
                    fetch(url)
                        .then(response => {
                            if (!response.ok) {
                                throw new Error(`HTTP error! status: ${response.status}`);
                            }
                            return response.json();
                        })
                        .then(data => {
                            const lyricText = processLyricsResponse(data);
                            if (lyricText) {
                                parseLyrics(lyricText);
                                state.apiStatus[state.currentApi] = 'online';
                            } else {
                                resetLyrics();
                            }
                            updateApiStatusDisplay();
                        })
                        .catch(error => {
                            console.error('加载歌词失败:', error);
                            resetLyrics();
                        });
                } catch (error) {
                    console.error('加载歌词时出错:', error);
                    resetLyrics();
                }
            }

            // 解析歌词
            function parseLyrics(lyricText) {
                try {
                    state.lyrics = [];
                    state.currentLyricIndex = -1;
                    
                    if (!lyricText) {
                        resetLyrics();
                        return;
                    }
                    
                    // 解析歌词
                    const lyricLines = lyricText.split('\n');
                    const lyricMap = new Map();
                    
                    lyricLines.forEach(line => {
                        const match = line.match(/\[(\d+):(\d+).(\d+)\](.*)/);
                        if (match) {
                            const minutes = parseInt(match[1]);
                            const seconds = parseInt(match[2]);
                            const milliseconds = parseInt(match[3]);
                            const text = match[4].trim();
                            
                            const time = minutes * 60 + seconds + milliseconds / 1000;
                            lyricMap.set(time, { time, text, translation: '' });
                        }
                    });
                    
                    // 转换为数组并排序
                    state.lyrics = Array.from(lyricMap.values()).sort((a, b) => a.time - b.time);
                    
                    // 渲染歌词
                    renderLyrics();
                } catch (error) {
                    console.error('解析歌词时出错:', error);
                    resetLyrics();
                }
            }

            // 渲染歌词
            function renderLyrics() {
                try {
                    if (state.lyrics.length === 0) {
                        elements.lyricsContainer.innerHTML = `
                            <div class="no-lyrics">
                                <i class="fas fa-music"></i>
                                <div>暂无歌词</div>
                            </div>
                        `;
                        elements.fullscreenLyrics.innerHTML = `
                            <div class="no-lyrics">
                                <i class="fas fa-music"></i>
                                <div>暂无歌词</div>
                            </div>
                        `;
                        return;
                    }
                    
                    let lyricsHtml = '';
                    let fullscreenLyricsHtml = '';
                    
                    state.lyrics.forEach((lyric, index) => {
                        const isCurrent = index === state.currentLyricIndex;
                        const className = isCurrent ? 'lyric-line current-lyric' : 'lyric-line';
                        
                        lyricsHtml += `<div class="${className}" data-index="${index}">${lyric.text}</div>`;
                        fullscreenLyricsHtml += `<div class="${className}" data-index="${index}">${lyric.text}</div>`;
                    });
                    
                    elements.lyricsContainer.innerHTML = lyricsHtml;
                    elements.fullscreenLyrics.innerHTML = fullscreenLyricsHtml;
                } catch (error) {
                    console.error('渲染歌词时出错:', error);
                    resetLyrics();
                }
            }

            // 重置歌词
            function resetLyrics() {
                try {
                    state.lyrics = [];
                    state.currentLyricIndex = -1;
                    
                    elements.lyricsContainer.innerHTML = `
                        <div class="no-lyrics">
                            <i class="fas fa-music"></i>
                            <div>暂无歌词</div>
                        </div>
                    `;
                    
                    elements.fullscreenLyrics.innerHTML = `
                        <div class="no-lyrics">
                            <i class="fas fa-music"></i>
                            <div>暂无歌词</div>
                        </div>
                    `;
                } catch (error) {
                    console.error('重置歌词时出错:', error);
                }
            }

            // 更新歌词高亮
            function updateLyricsHighlight() {
                try {
                    if (state.lyrics.length === 0) return;
                    
                    const currentTime = state.audioPlayer.currentTime;
                    let newIndex = -1;
                    
                    // 找到当前时间对应的歌词
                    for (let i = state.lyrics.length - 1; i >= 0; i--) {
                        if (currentTime >= state.lyrics[i].time) {
                            newIndex = i;
                            break;
                        }
                    }
                    
                    // 如果歌词索引发生变化，更新高亮
                    if (newIndex !== state.currentLyricIndex) {
                        state.currentLyricIndex = newIndex;
                        
                        // 更新歌词面板
                        const lyricLines = elements.lyricsContainer.querySelectorAll('.lyric-line');
                        lyricLines.forEach((line, index) => {
                            if (index === newIndex) {
                                line.className = 'lyric-line current-lyric';
                                
                                // 滚动到当前歌词
                                line.scrollIntoView({
                                    behavior: 'smooth',
                                    block: 'center'
                                });
                            } else {
                                line.className = 'lyric-line';
                            }
                        });
                        
                        // 更新全屏歌词
                        const fullscreenLyricLines = elements.fullscreenLyrics.querySelectorAll('.lyric-line');
                        fullscreenLyricLines.forEach((line, index) => {
                            if (index === newIndex) {
                                line.className = 'lyric-line current-lyric';
                            } else {
                                line.className = 'lyric-line';
                            }
                        });
                    }
                } catch (error) {
                    console.error('更新歌词高亮时出错:', error);
                }
            }

            // 添加到播放历史
            function addToPlayHistory(song) {
                try {
                    // 检查是否已存在
                    const existingIndex = state.playHistory.findIndex(item => 
                        item.id === song.id && item.source === song.source
                    );
                    
                    // 如果已存在，先移除
                    if (existingIndex !== -1) {
                        state.playHistory.splice(existingIndex, 1);
                    }
                    
                    // 添加到开头
                    state.playHistory.unshift(song);
                    
                    // 限制历史记录数量
                    if (state.playHistory.length > 100) {
                        state.playHistory.pop();
                    }
                    
                    saveUserData();
                } catch (error) {
                    console.error('添加到播放历史时出错:', error);
                }
            }

            // 切换播放状态
            function togglePlay() {
                try {
                    if (state.currentSongIndex === -1 && state.songs.length > 0) {
                        // 如果没有当前歌曲，播放第一首
                        playSong(state.songs[0], 0);
                    } else if (state.currentSongIndex !== -1) {
                        // 切换播放/暂停状态
                        if (state.isPlaying) {
                            state.audioPlayer.pause();
                            state.isPlaying = false;
                        } else {
                            state.audioPlayer.play().then(() => {
                                state.isPlaying = true;
                            }).catch(error => {
                                console.error('播放失败:', error);
                                showError('播放失败，请尝试其他歌曲');
                            });
                        }
                        
                        updateAllPlayButtons();
                        updateSongListActiveState();
                    }
                } catch (error) {
                    console.error('切换播放状态时出错:', error);
                    showError('播放控制失败');
                }
            }

            // 播放上一首
            function playPrev() {
                try {
                    if (state.songs.length === 0) return;
                    
                    let newIndex;
                    
                    if (state.isShuffled) {
                        // 随机播放模式
                        newIndex = Math.floor(Math.random() * state.songs.length);
                    } else {
                        // 顺序播放模式
                        newIndex = state.currentSongIndex - 1;
                        if (newIndex < 0) {
                            newIndex = state.songs.length - 1;
                        }
                    }
                    
                    playSong(state.songs[newIndex], newIndex);
                } catch (error) {
                    console.error('播放上一首时出错:', error);
                    showError('切换歌曲失败');
                }
            }

            // 播放下一首
            function playNext() {
                try {
                    if (state.songs.length === 0) return;
                    
                    let newIndex;
                    
                    if (state.isShuffled) {
                        // 随机播放模式
                        newIndex = Math.floor(Math.random() * state.songs.length);
                    } else {
                        // 顺序播放模式
                        newIndex = state.currentSongIndex + 1;
                        if (newIndex >= state.songs.length) {
                            if (state.repeatMode === 'all') {
                                newIndex = 0;
                            } else {
                                // 停止播放
                                state.audioPlayer.pause();
                                state.isPlaying = false;
                                updateAllPlayButtons();
                                updateSongListActiveState();
                                return;
                            }
                        }
                    }
                    
                    playSong(state.songs[newIndex], newIndex);
                } catch (error) {
                    console.error('播放下一首时出错:', error);
                    showError('切换歌曲失败');
                }
            }

            // 随机播放
            function playShuffle() {
                try {
                    if (state.songs.length === 0) return;
                    
                    const randomIndex = Math.floor(Math.random() * state.songs.length);
                    playSong(state.songs[randomIndex], randomIndex);
                } catch (error) {
                    console.error('随机播放时出错:', error);
                    showError('随机播放失败');
                }
            }

            // 切换随机播放
            function toggleShuffle() {
                try {
                    state.isShuffled = !state.isShuffled;
                    updateShuffleButton();
                    savePlayerState();
                } catch (error) {
                    console.error('切换随机播放时出错:', error);
                }
            }

            // 更新随机播放按钮
            function updateShuffleButton() {
                try {
                    const icon = state.isShuffled ? 
                        '<i class="fas fa-random" style="color: var(--primary);"></i>' : 
                        '<i class="fas fa-random"></i>';
                    
                    elements.shuffleBtn.innerHTML = icon;
                    elements.fullscreenShuffleBtn.innerHTML = icon;
                } catch (error) {
                    console.error('更新随机播放按钮时出错:', error);
                }
            }

            // 切换循环模式
            function toggleRepeat() {
                try {
                    const modes = ['off', 'all', 'one'];
                    const currentIndex = modes.indexOf(state.repeatMode);
                    state.repeatMode = modes[(currentIndex + 1) % modes.length];
                    updateRepeatButton();
                    savePlayerState();
                } catch (error) {
                    console.error('切换循环模式时出错:', error);
                }
            }

            // 更新循环模式按钮
            function updateRepeatButton() {
                try {
                    let icon;
                    
                    switch (state.repeatMode) {
                        case 'off':
                            icon = '<i class="fas fa-redo"></i>';
                            break;
                        case 'all':
                            icon = '<i class="fas fa-redo" style="color: var(--primary);"></i>';
                            break;
                        case 'one':
                            icon = '<i class="fas fa-redo" style="color: var(--primary);"><span style="font-size: 8px; position: absolute; top: -2px; right: -2px;">1</span></i>';
                            break;
                    }
                    
                    elements.repeatBtn.innerHTML = icon;
                    elements.fullscreenRepeatBtn.innerHTML = icon;
                } catch (error) {
                    console.error('更新循环模式按钮时出错:', error);
                }
            }

            // 更新所有播放按钮
            function updateAllPlayButtons() {
                try {
                    const playIcon = state.isPlaying ? 
                        '<i class="fas fa-pause"></i>' : 
                        '<i class="fas fa-play"></i>';
                    
                    elements.playBtn.innerHTML = playIcon;
                    elements.mobilePlayBtn.innerHTML = playIcon;
                    elements.fullscreenPlayBtn.innerHTML = playIcon;
                } catch (error) {
                    console.error('更新所有播放按钮时出错:', error);
                }
            }

            // 更新歌曲列表活动状态
            function updateSongListActiveState() {
                try {
                    document.querySelectorAll('.song-item').forEach((item, index) => {
                        if (index === state.currentSongIndex && state.isPlaying) {
                            item.classList.add('active');
                        } else {
                            item.classList.remove('active');
                        }
                    });
                } catch (error) {
                    console.error('更新歌曲列表活动状态时出错:', error);
                }
            }

            // 更新进度
            function updateProgress() {
                try {
                    if (!state.audioPlayer.duration) return;
                    
                    const currentTime = state.audioPlayer.currentTime;
                    const duration = state.audioPlayer.duration;
                    const percent = (currentTime / duration) * 100;
                    
                    elements.progress.style.width = `${percent}%`;
                    elements.fullscreenProgress.style.width = `${percent}%`;
                    
                    elements.currentTime.textContent = formatTime(currentTime);
                    elements.fullscreenCurrentTime.textContent = formatTime(currentTime);
                    
                    // 更新歌词高亮
                    updateLyricsHighlight();
                    
                    // 保存播放状态
                    savePlayerState();
                } catch (error) {
                    console.error('更新进度时出错:', error);
                }
            }

            // 跳转进度
            function seek(e) {
                try {
                    if (!state.audioPlayer.duration) return;
                    
                    const progressBar = elements.progressBar;
                    const rect = progressBar.getBoundingClientRect();
                    const percent = (e.clientX - rect.left) / rect.width;
                    const newTime = percent * state.audioPlayer.duration;
                    
                    state.audioPlayer.currentTime = newTime;
                } catch (error) {
                    console.error('跳转进度时出错:', error);
                }
            }

            // 全屏模式跳转进度
            function fullscreenSeek(e) {
                try {
                    if (!state.audioPlayer.duration) return;
                    
                    const progressBar = elements.fullscreenProgressBar;
                    const rect = progressBar.getBoundingClientRect();
                    const percent = (e.clientX - rect.left) / rect.width;
                    const newTime = percent * state.audioPlayer.duration;
                    
                    state.audioPlayer.currentTime = newTime;
                } catch (error) {
                    console.error('全屏模式跳转进度时出错:', error);
                }
            }

            // 切换静音
            function toggleMute() {
                try {
                    state.isMuted = !state.isMuted;
                    state.audioPlayer.muted = state.isMuted;
                    
                    const icon = state.isMuted ? 
                        '<i class="fas fa-volume-mute"></i>' : 
                        '<i class="fas fa-volume-up"></i>';
                    
                    elements.volumeBtn.innerHTML = icon;
                    
                    savePlayerState();
                } catch (error) {
                    console.error('切换静音时出错:', error);
                }
            }

            // 改变音量
            function changeVolume() {
                try {
                    state.volume = elements.volumeSlider.value;
                    state.audioPlayer.volume = state.volume / 100;
                    
                    // 更新静音状态
                    if (state.volume == 0) {
                        state.isMuted = true;
                        state.audioPlayer.muted = true;
                        elements.volumeBtn.innerHTML = '<i class="fas fa-volume-mute"></i>';
                    } else if (state.isMuted) {
                        state.isMuted = false;
                        state.audioPlayer.muted = false;
                        elements.volumeBtn.innerHTML = '<i class="fas fa-volume-up"></i>';
                    }
                    
                    savePlayerState();
                } catch (error) {
                    console.error('改变音量时出错:', error);
                }
            }

            // 切换歌词面板
            function toggleLyrics() {
                try {
                    state.isLyricsVisible = !state.isLyricsVisible;
                    
                    if (state.isLyricsVisible) {
                        elements.lyricsPanel.classList.add('open');
                    } else {
                        elements.lyricsPanel.classList.remove('open');
                    }
                } catch (error) {
                    console.error('切换歌词面板时出错:', error);
                }
            }

            // 进入全屏模式
            function enterFullscreen() {
                try {
                    state.isFullscreen = true;
                    elements.fullscreenOverlay.classList.add('active');
                    
                    // 更新全屏界面信息
                    if (state.currentSongIndex !== -1) {
                        const song = state.songs[state.currentSongIndex];
                        elements.fullscreenTitle.textContent = song.name;
                        elements.fullscreenArtist.textContent = song.artistsname || song.artist;
                        elements.fullscreenAlbum.textContent = song.album || '未知专辑';
                        
                        // 更新播放按钮状态
                        elements.fullscreenPlayBtn.innerHTML = state.isPlaying ? 
                            '<i class="fas fa-pause"></i>' : 
                            '<i class="fas fa-play"></i>';
                    }
                    
                    // 更新控制按钮状态
                    updateShuffleButton();
                    updateRepeatButton();
                    updateFavoriteButtonState();
                } catch (error) {
                    console.error('进入全屏模式时出错:', error);
                }
            }

            // 退出全屏模式
            function exitFullscreen() {
                try {
                    state.isFullscreen = false;
                    elements.fullscreenOverlay.classList.remove('active');
                } catch (error) {
                    console.error('退出全屏模式时出错:', error);
                }
            }

            // 处理歌曲结束
            function handleSongEnd() {
                try {
                    if (state.repeatMode === 'one') {
                        // 单曲循环
                        state.audioPlayer.currentTime = 0;
                        state.audioPlayer.play();
                    } else {
                        // 播放下一首或停止
                        playNext();
                    }
                } catch (error) {
                    console.error('处理歌曲结束时出错:', error);
                }
            }

            // 处理音频错误
            function handleAudioError() {
                try {
                    console.error('音频播放错误:', state.audioPlayer.error);
                    showError('音频播放错误，请尝试其他歌曲');
                    state.isPlaying = false;
                    updateAllPlayButtons();
                    updateSongListActiveState();
                } catch (error) {
                    console.error('处理音频错误时出错:', error);
                }
            }

            // 切换收藏
            function toggleFavorite(song, index) {
                try {
                    const isFavorited = state.favoriteMusic.some(fav => 
                        fav.id === song.id && fav.source === song.source
                    );
                    
                    if (isFavorited) {
                        // 取消收藏
                        state.favoriteMusic = state.favoriteMusic.filter(fav => 
                            !(fav.id === song.id && fav.source === song.source)
                        );
                        showSuccess('已取消收藏');
                    } else {
                        // 添加收藏
                        state.favoriteMusic.unshift(song);
                        showSuccess('已添加到收藏');
                    }
                    
                    saveUserData();
                    
                    // 更新按钮状态
                    const favoriteBtn = document.querySelector(`.song-item[data-index="${index}"] .song-action-btn[data-action="favorite"]`);
                    if (favoriteBtn) {
                        if (isFavorited) {
                            favoriteBtn.classList.remove('favorited');
                        } else {
                            favoriteBtn.classList.add('favorited');
                        }
                    }
                    
                    // 更新播放器收藏按钮状态
                    updateFavoriteButtonState(song);
                } catch (error) {
                    console.error('切换收藏时出错:', error);
                    showError('收藏操作失败');
                }
            }

            // 切换当前歌曲收藏
            function toggleCurrentSongFavorite() {
                try {
                    if (state.currentSongIndex === -1) return;
                    
                    const song = state.songs[state.currentSongIndex];
                    toggleFavorite(song, state.currentSongIndex);
                } catch (error) {
                    console.error('切换当前歌曲收藏时出错:', error);
                    showError('收藏操作失败');
                }
            }

            // 更新收藏按钮状态
            function updateFavoriteButtonState(song = null) {
                try {
                    const currentSong = song || (state.currentSongIndex !== -1 ? state.songs[state.currentSongIndex] : null);
                    
                    if (!currentSong) {
                        elements.favoriteBtn.classList.remove('favorited');
                        elements.fullscreenFavoriteBtn.classList.remove('favorited');
                        elements.mobileFavoriteBtn.classList.remove('favorited');
                        return;
                    }
                    
                    const isFavorited = state.favoriteMusic.some(fav => 
                        fav.id === currentSong.id && fav.source === currentSong.source
                    );
                    
                    if (isFavorited) {
                        elements.favoriteBtn.classList.add('favorited');
                        elements.fullscreenFavoriteBtn.classList.add('favorited');
                        elements.mobileFavoriteBtn.classList.add('favorited');
                    } else {
                        elements.favoriteBtn.classList.remove('favorited');
                        elements.fullscreenFavoriteBtn.classList.remove('favorited');
                        elements.mobileFavoriteBtn.classList.remove('favorited');
                    }
                } catch (error) {
                    console.error('更新收藏按钮状态时出错:', error);
                }
            }

            // 添加到待播放列表
            function addToUpNext(song) {
                try {
                    // 检查是否已存在
                    const existingIndex = state.upNextSongs.findIndex(item => 
                        item.id === song.id && item.source === song.source
                    );
                    
                    if (existingIndex === -1) {
                        state.upNextSongs.push(song);
                        saveUserData();
                        renderUpNextList();
                        showSuccess('已添加到待播放列表');
                    } else {
                        showSuccess('歌曲已在待播放列表中');
                    }
                } catch (error) {
                    console.error('添加到待播放列表时出错:', error);
                    showError('添加到待播放列表失败');
                }
            }

            // 切换待播放列表
            function toggleUpNext() {
                try {
                    state.isUpNextVisible = !state.isUpNextVisible;
                    
                    if (state.isUpNextVisible) {
                        elements.upNextPanel.classList.add('open');
                    } else {
                        elements.upNextPanel.classList.remove('open');
                    }
                } catch (error) {
                    console.error('切换待播放列表时出错:', error);
                }
            }

            // 渲染待播放列表
            function renderUpNextList() {
                try {
                    if (state.upNextSongs.length === 0) {
                        elements.upNextList.innerHTML = `
                            <div class="upnext-empty">
                                <i class="fas fa-list"></i>
                                <p>待播放列表为空</p>
                                <p>点击歌曲的"添加到待播放列表"按钮来添加歌曲</p>
                            </div>
                        `;
                        return;
                    }
                    
                    let html = '';
                    
                    state.upNextSongs.forEach((song, index) => {
                        const isActive = state.currentSongIndex === index && state.isPlaying;
                        
                        html += `
                            <div class="upnext-item ${isActive ? 'active' : ''}" data-index="${index}">
                                <div class="upnext-number">${index + 1}</div>
                                <div class="upnext-info">
                                    <div class="upnext-name">${song.name}</div>
                                    <div class="upnext-artist">${song.artistsname || song.artist}</div>
                                </div>
                                <div class="upnext-actions-item">
                                    <button class="upnext-action-btn-item play-upnext-btn" data-index="${index}">
                                        <i class="fas fa-play"></i>
                                    </button>
                                    <button class="upnext-action-btn-item remove-upnext-btn" data-index="${index}">
                                        <i class="fas fa-times"></i>
                                    </button>
                                </div>
                            </div>
                        `;
                    });
                    
                    elements.upNextList.innerHTML = html;
                    
                    // 添加事件监听器
                    document.querySelectorAll('.upnext-item').forEach(item => {
                        item.addEventListener('click', (e) => {
                            if (!e.target.closest('.upnext-actions-item')) {
                                const index = parseInt(item.dataset.index);
                                playUpNextSong(index);
                            }
                        });
                    });
                    
                    document.querySelectorAll('.play-upnext-btn').forEach(btn => {
                        btn.addEventListener('click', (e) => {
                            e.stopPropagation();
                            const index = parseInt(btn.dataset.index);
                            playUpNextSong(index);
                        });
                    });
                    
                    document.querySelectorAll('.remove-upnext-btn').forEach(btn => {
                        btn.addEventListener('click', (e) => {
                            e.stopPropagation();
                            const index = parseInt(btn.dataset.index);
                            removeFromUpNext(index);
                        });
                    });
                } catch (error) {
                    console.error('渲染待播放列表时出错:', error);
                }
            }

            // 播放待播放列表中的歌曲
            function playUpNextSong(index) {
                try {
                    const song = state.upNextSongs[index];
                    playSong(song, index, state.upNextSongs);
                    toggleUpNext();
                } catch (error) {
                    console.error('播放待播放列表中的歌曲时出错:', error);
                    showError('播放歌曲失败');
                }
            }

            // 从待播放列表中移除
            function removeFromUpNext(index) {
                try {
                    state.upNextSongs.splice(index, 1);
                    saveUserData();
                    renderUpNextList();
                } catch (error) {
                    console.error('从待播放列表中移除时出错:', error);
                    showError('移除歌曲失败');
                }
            }

            // 清空待播放列表
            function clearUpNext() {
                try {
                    if (state.upNextSongs.length === 0) return;
                    
                    if (confirm('确定要清空待播放列表吗？')) {
                        state.upNextSongs = [];
                        saveUserData();
                        renderUpNextList();
                        showSuccess('待播放列表已清空');
                    }
                } catch (error) {
                    console.error('清空待播放列表时出错:', error);
                    showError('清空待播放列表失败');
                }
            }

            // 随机播放待播放列表
            function shuffleUpNext() {
                try {
                    if (state.upNextSongs.length === 0) return;
                    
                    // 随机排序
                    for (let i = state.upNextSongs.length - 1; i > 0; i--) {
                        const j = Math.floor(Math.random() * (i + 1));
                        [state.upNextSongs[i], state.upNextSongs[j]] = [state.upNextSongs[j], state.upNextSongs[i]];
                    }
                    
                    saveUserData();
                    renderUpNextList();
                    showSuccess('待播放列表已随机排序');
                } catch (error) {
                    console.error('随机播放待播放列表时出错:', error);
                    showError('随机排序失败');
                }
            }

            // 显示下载选项
            function showDownloadOptions(song) {
                try {
                    state.currentDownloadSong = song;
                    elements.downloadModal.classList.add('active');
                } catch (error) {
                    console.error('显示下载选项时出错:', error);
                    showError('显示下载选项失败');
                }
            }

            // 处理下载
            function handleDownload() {
                try {
                    if (!state.currentDownloadSong) return;
                    
                    const downloadAudio = elements.downloadAudioCheckbox.checked;
                    const downloadAlbumArt = elements.downloadAlbumArtCheckbox.checked;
                    const downloadLyrics = elements.downloadLyricsCheckbox.checked;
                    
                    // 获取选中的音频格式
                    let audioFormat = 'mp3';
                    elements.audioFormatRadios.forEach(radio => {
                        if (radio.checked) {
                            audioFormat = radio.value;
                        }
                    });
                    
                    // 获取选中的歌词格式
                    let lyricsFormat = 'lrc';
                    elements.lyricsFormatRadios.forEach(radio => {
                        if (radio.checked) {
                            lyricsFormat = radio.value;
                        }
                    });
                    
                    // 开始下载
                    downloadSong(
                        state.currentDownloadSong, 
                        downloadAudio, 
                        downloadAlbumArt, 
                        downloadLyrics, 
                        audioFormat, 
                        lyricsFormat
                    );
                    
                    // 关闭模态框
                    elements.downloadModal.classList.remove('active');
                } catch (error) {
                    console.error('处理下载时出错:', error);
                    showError('下载失败');
                }
            }

            // 下载歌曲
            function downloadSong(song, downloadAudio, downloadAlbumArt, downloadLyrics, audioFormat, lyricsFormat) {
                try {
                    // 创建下载记录
                    const download = {
                        id: song.id,
                        name: song.name,
                        artist: song.artistsname || song.artist,
                        source: song.source,
                        date: new Date().toISOString(),
                        audioFormat: audioFormat,
                        lyricsFormat: lyricsFormat
                    };
                    
                    // 添加到下载列表
                    state.downloads.unshift(download);
                    
                    // 限制下载记录数量
                    if (state.downloads.length > 100) {
                        state.downloads.pop();
                    }
                    
                    saveUserData();
                    
                    // 显示下载开始消息
                    showSuccess('开始下载歌曲...');
                    
                    // 模拟下载过程
                    setTimeout(() => {
                        showSuccess(`"${song.name}" 下载完成`);
                    }, 2000);
                } catch (error) {
                    console.error('下载歌曲时出错:', error);
                    showError('下载失败');
                }
            }

            // 格式化时间
            function formatTime(seconds) {
                try {
                    const mins = Math.floor(seconds / 60);
                    const secs = Math.floor(seconds % 60);
                    return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
                } catch (error) {
                    console.error('格式化时间时出错:', error);
                    return '--:--';
                }
            }

            // 显示加载状态
            function showLoading() {
                try {
                    elements.loadingIndicator.style.display = 'flex';
                    elements.errorMessage.classList.remove('show');
                } catch (error) {
                    console.error('显示加载状态时出错:', error);
                }
            }

            // 隐藏加载状态
            function hideLoading() {
                try {
                    elements.loadingIndicator.style.display = 'none';
                } catch (error) {
                    console.error('隐藏加载状态时出错:', error);
                }
            }

            // 显示错误
            function showError(message) {
                try {
                    elements.errorText.textContent = message;
                    elements.errorMessage.classList.add('show');
                } catch (error) {
                    console.error('显示错误时出错:', error);
                }
            }

            // 隐藏错误
            function hideError() {
                try {
                    elements.errorMessage.classList.remove('show');
                } catch (error) {
                    console.error('隐藏错误时出错:', error);
                }
            }

            // 显示成功消息
            function showSuccess(message) {
                try {
                    const toast = document.createElement('div');
                    toast.className = 'success-toast';
                    toast.innerHTML = `
                        <i class="fas fa-check-circle"></i>
                        <span>${message}</span>
                    `;
                    
                    document.body.appendChild(toast);
                    
                    // 3秒后移除
                    setTimeout(() => {
                        toast.style.animation = 'slideOutRight 0.3s ease';
                        setTimeout(() => {
                            if (toast.parentNode) {
                                toast.parentNode.removeChild(toast);
                            }
                        }, 300);
                    }, 3000);
                } catch (error) {
                    console.error('显示成功消息时出错:', error);
                }
            }

            // 加载榜单数据
            function loadCharts(forceRefresh = false) {
                try {
                    const now = Date.now();
                    const oneHour = 60 * 60 * 1000;
                    
                    // 检查是否需要刷新数据
                    if (!forceRefresh && 
                        state.chartsData && 
                        now - state.chartsLastUpdated < oneHour) {
                        // 使用缓存数据
                        renderCharts();
                        return;
                    }
                    
                    showChartsLoading();
                    
                    // 获取榜单数据 - 目前只支持主用API
                    const chartsUrl = API_CONFIG.main.charts;
                    
                    fetch(chartsUrl)
                        .then(response => {
                            if (!response.ok) {
                                throw new Error(`HTTP error! status: ${response.status}`);
                            }
                            return response.json();
                        })
                        .then(data => {
                            hideChartsLoading();
                            
                            if (data && data.data) {
                                state.chartsData = data.data;
                                state.chartsLastUpdated = now;
                                
                                // 保存到本地存储
                                localStorage.setItem('yueyinge_charts_data', JSON.stringify(state.chartsData));
                                localStorage.setItem('yueyinge_charts_last_updated', state.chartsLastUpdated.toString());
                                
                                renderCharts();
                            } else {
                                showChartsError('获取榜单数据失败');
                            }
                        })
                        .catch(error => {
                            hideChartsLoading();
                            console.error('加载榜单数据失败:', error);
                            showChartsError('加载榜单数据失败，请检查网络连接');
                        });
                } catch (error) {
                    hideChartsLoading();
                    console.error('加载榜单数据时出错:', error);
                    showChartsError('加载榜单数据失败');
                }
            }

            // 显示榜单加载状态
            function showChartsLoading() {
                try {
                    elements.chartsGrid.innerHTML = `
                        <div class="loading">
                            <i class="fas fa-spinner"></i>
                            <span>加载榜单中...</span>
                        </div>
                    `;
                } catch (error) {
                    console.error('显示榜单加载状态时出错:', error);
                }
            }

            // 隐藏榜单加载状态
            function hideChartsLoading() {
                try {
                    // 加载状态会在渲染时被替换
                } catch (error) {
                    console.error('隐藏榜单加载状态时出错:', error);
                }
            }

            // 显示榜单错误
            function showChartsError(message) {
                try {
                    elements.chartsGrid.innerHTML = `
                        <div class="error-message show" style="grid-column: 1 / -1;">
                            <i class="fas fa-exclamation-circle"></i>
                            <span>${message}</span>
                        </div>
                    `;
                } catch (error) {
                    console.error('显示榜单错误时出错:', error);
                }
            }

            // 渲染榜单
            function renderCharts() {
                try {
                    if (!state.chartsData || state.chartsData.length === 0) {
                        showChartsError('暂无榜单数据');
                        return;
                    }
                    
                    let html = '';
                    
                    // 只显示前8个榜单
                    state.chartsData.slice(0, 8).forEach(chart => {
                        html += `
                            <div class="card" data-id="${chart.id}">
                                <div class="card-image">
                                    <i class="fas fa-chart-line" style="font-size: 48px;"></i>
                                </div>
                                <div class="card-title">${chart.name}</div>
                                <div class="card-description">${chart.description || '热门音乐榜单'}</div>
                                <div class="card-play-btn">
                                    <i class="fas fa-play"></i>
                                </div>
                            </div>
                        `;
                    });
                    
                    elements.chartsGrid.innerHTML = html;
                    
                    // 添加点击事件
                    document.querySelectorAll('#chartsGrid .card').forEach(card => {
                        card.addEventListener('click', () => {
                            const chartId = card.dataset.id;
                            loadChartSongs(chartId);
                        });
                    });
                } catch (error) {
                    console.error('渲染榜单时出错:', error);
                    showChartsError('渲染榜单失败');
                }
            }

            // 加载榜单歌曲
            function loadChartSongs(chartId) {
                try {
                    state.currentView = 'chart';
                    elements.playlistTitle.textContent = '榜单歌曲';
                    
                    showLoading();
                    
                    // 构建榜单歌曲URL - 目前只支持主用API
                    const url = `${API_CONFIG.main.charts}?id=${chartId}`;
                    
                    fetch(url)
                        .then(response => {
                            if (!response.ok) {
                                throw new Error(`HTTP error! status: ${response.status}`);
                            }
                            return response.json();
                        })
                        .then(data => {
                            hideLoading();
                            
                            if (data && data.data && data.data.songs) {
                                // 转换歌曲格式
                                const songs = data.data.songs.map(song => ({
                                    name: song.name,
                                    artist: song.artists.map(artist => artist.name).join(', '),
                                    artistsname: song.artists.map(artist => artist.name).join(', '),
                                    id: song.id,
                                    source: 'netease',
                                    duration: song.duration,
                                    album: song.album ? song.album.name : '未知专辑'
                                }));
                                
                                state.songs = songs;
                                renderSongList(songs);
                            } else {
                                showError('加载榜单歌曲失败');
                            }
                        })
                        .catch(error => {
                            hideLoading();
                            console.error('加载榜单歌曲失败:', error);
                            showError('加载榜单歌曲失败，请检查网络连接');
                        });
                } catch (error) {
                    hideLoading();
                    console.error('加载榜单歌曲时出错:', error);
                    showError('加载榜单歌曲失败');
                }
            }

            // 初始化应用
            initApp();
        });
    </script>
</body>
</html>